:root {
  color-scheme: light;
  --ink: #232321;
  --muted: #726f69;
  --ivory: #f6f0e7;
  --paper: #fffdf8;
  --paper-warm: #fbf7f0;
  --line: #ded7cd;
  --coral: #e96555;
  --coral-dark: #c84c40;
  --coral-soft: #f9e3dd;
  --teal: #155f63;
  --teal-soft: #dceceb;
  --gold: #e4a824;
  --success: #27765f;
  --shadow: 0 20px 55px rgba(56, 47, 38, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 2% 2%, rgba(233, 101, 85, 0.13), transparent 22rem),
    radial-gradient(circle at 96% 8%, rgba(21, 95, 99, 0.09), transparent 25rem),
    var(--ivory);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(21, 95, 99, 0.32); outline-offset: 3px; }

.site-shell { min-height: 100vh; }

.site-header {
  position: relative;
  z-index: 10;
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px clamp(20px, 3vw, 54px);
  border-bottom: 1px solid rgba(109, 99, 88, 0.18);
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(18px);
}

.header-actions { display: flex; align-items: center; gap: 18px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px 13px 13px 4px;
  color: white;
  background: var(--coral);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 1.28rem;
  font-weight: 850;
  box-shadow: 0 8px 18px rgba(201, 76, 64, 0.22);
}

.brand > span:last-child { display: grid; gap: 1px; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; letter-spacing: 0.13em; }
.brand small { color: var(--muted); font-size: 0.69rem; }

.header-progress {
  display: grid;
  grid-template-columns: auto minmax(90px, 170px) auto;
  align-items: center;
  gap: 11px;
}

.header-progress > span { color: var(--teal); font-size: 0.65rem; font-weight: 850; letter-spacing: 0.12em; }
.header-progress > strong { font-size: 0.72rem; white-space: nowrap; }
.header-track { width: 100%; height: 6px; overflow: hidden; border-radius: 999px; background: #e4ded5; }
.header-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #4a9b94); transition: width 350ms ease; }

.header-flashcards {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding: 8px 10px 8px 12px;
  border: 1px solid rgba(233, 101, 85, 0.24);
  border-radius: 999px;
  color: var(--coral-dark);
  background: var(--coral-soft);
  cursor: pointer;
  font-size: .72rem;
  font-weight: 850;
}
.header-flashcards > span { font-size: .82rem; }
.header-flashcards b { display: grid; min-width: 22px; height: 22px; padding: 0 5px; place-items: center; border-radius: 999px; color: white; background: var(--coral); font-size: .64rem; }

.learning-shell {
  display: grid;
  grid-template-columns: minmax(235px, 0.68fr) minmax(440px, 1.35fr) minmax(330px, 0.87fr);
  min-height: calc(100vh - 78px);
}

.lesson-library {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 32px 22px 28px clamp(20px, 3vw, 46px);
  border-right: 1px solid rgba(109, 99, 88, 0.17);
  background: rgba(249, 245, 237, 0.76);
}

.library-heading p, .reader-heading p, .speaker-header p {
  margin: 0 0 8px;
  color: var(--coral-dark);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.library-heading h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 2.25vw, 2.05rem);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.library-heading > span { display: block; margin-top: 10px; color: var(--muted); font-size: 0.76rem; line-height: 1.4; }

.lesson-list { display: grid; gap: 9px; margin-top: 27px; }
.library-loading { padding: 18px 4px; color: var(--muted); font-size: 0.82rem; }

.lesson-button {
  position: relative;
  display: grid;
  width: 100%;
  grid-template-columns: 35px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 11px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.lesson-button:hover { transform: translateX(2px); background: rgba(255, 255, 255, 0.67); }
.lesson-button.active { border-color: rgba(21, 95, 99, 0.22); background: var(--paper); box-shadow: 0 9px 25px rgba(45, 42, 36, 0.08); }
.lesson-button.active::before { content: ""; position: absolute; top: 11px; bottom: 11px; left: -1px; width: 3px; border-radius: 0 5px 5px 0; background: var(--coral); }

.lesson-number {
  display: grid;
  width: 33px;
  height: 33px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #f9f5ed;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.71rem;
  font-weight: 800;
}

.lesson-button.active .lesson-number { border-color: var(--coral); color: white; background: var(--coral); }
.lesson-copy { min-width: 0; }
.lesson-copy strong, .lesson-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-copy strong { font-family: Georgia, "Times New Roman", serif; font-size: 0.89rem; }
.lesson-copy small { margin-top: 3px; color: var(--muted); font-size: 0.67rem; }
.lesson-percent { color: var(--teal); font-size: 0.65rem; font-weight: 850; }

.library-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(228, 168, 36, 0.27);
  border-radius: 14px;
  background: #fff8e5;
}

.library-note > span { color: var(--gold); }
.library-note p { margin: 0; color: var(--muted); font-size: 0.71rem; line-height: 1.4; }
.library-note strong { display: block; margin-bottom: 2px; color: var(--ink); }

.lesson-reader { min-width: 0; padding: 32px clamp(20px, 2.4vw, 40px) 48px; }
.reader-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.reader-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.7rem, 2.8vw, 2.55rem); line-height: 1.06; letter-spacing: -0.035em; }
.progress-pill { flex: 0 0 auto; padding: 7px 10px; border: 1px solid rgba(21, 95, 99, 0.18); border-radius: 999px; color: var(--teal); background: var(--teal-soft); font-size: 0.67rem; font-weight: 850; }

.goal-row { display: flex; min-height: 31px; gap: 7px; margin-top: 15px; overflow: auto; scrollbar-width: none; }
.goal-row::-webkit-scrollbar { display: none; }
.goal-chip { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: #635f59; background: rgba(255,255,255,0.56); font-size: 0.66rem; }
.goal-chip::before { content: "✓"; margin-right: 5px; color: var(--teal); font-weight: 900; }

.page-strip-wrap { display: grid; grid-template-columns: 32px 1fr 32px; align-items: center; gap: 7px; margin: 22px 0 14px; }
.page-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.page-arrow { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,0.7); cursor: pointer; }
.page-arrow:disabled { opacity: 0.35; cursor: not-allowed; }

.page-tab { min-width: 0; padding: 7px 4px; border: 0; border-bottom: 2px solid #d7d0c7; color: var(--muted); background: transparent; cursor: pointer; font-size: 0.66rem; font-weight: 800; transition: color 160ms ease, border-color 160ms ease; }
.page-tab:hover { color: var(--coral-dark); }
.page-tab.active { border-color: var(--coral); color: var(--coral-dark); }
.page-tab.complete::after { content: " ·"; color: var(--success); }

.manga-card { overflow: hidden; border: 1px solid rgba(96, 87, 77, 0.2); border-radius: 21px; background: var(--paper); box-shadow: var(--shadow); }
.manga-meta { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 15px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.manga-meta > div { display: grid; gap: 3px; }
.manga-meta span { color: var(--coral-dark); font-size: 0.61rem; font-weight: 900; letter-spacing: 0.12em; }
.manga-meta strong { font-family: Georgia, "Times New Roman", serif; font-size: 0.98rem; }
.manga-meta p { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--muted); font-size: 0.68rem; }
.manga-meta p i { width: 7px; height: 7px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 0 rgba(233,101,85,.5); animation: pulse 1.8s infinite; }

@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(233,101,85,0); } 100% { box-shadow: 0 0 0 0 rgba(233,101,85,0); } }

.manga-stage { position: relative; width: 100%; min-height: 300px; overflow: hidden; background: #ebe7e0; line-height: 0; }
.manga-stage img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.hotspot-layer { position: absolute; inset: 0; }

.hotspot {
  position: absolute;
  padding: 0;
  border: 2px solid rgba(233, 101, 85, 0.58);
  background: rgba(255, 253, 248, 0.03);
  cursor: pointer;
  filter: drop-shadow(0 2px 1px rgba(255,255,255,.8));
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.hotspot::before { content: ""; position: absolute; inset: -6px; border: 1px solid rgba(255,255,255,0.75); border-radius: inherit; }
.hotspot:hover, .hotspot:focus-visible { outline: none; border-color: var(--teal); background: rgba(21,95,99,0.1); box-shadow: 0 0 0 5px rgba(255,255,255,.75); transform: scale(1.02); }
.hotspot.active { border-color: var(--coral); background: rgba(233,101,85,0.17); box-shadow: 0 0 0 5px rgba(255,255,255,.82), 0 8px 22px rgba(92,49,40,.23); transform: scale(1.018); }
.hotspot.explored::after { content: "✓"; position: absolute; top: -11px; right: -8px; display: grid; width: 23px; height: 23px; place-items: center; border: 2px solid white; border-radius: 50%; color: white; background: var(--success); font-size: 0.66rem; font-weight: 900; line-height: 1; }

.image-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: #eee9e0; font-size: 0.78rem; line-height: 1.3; }
.image-loading.hidden { display: none; }

.study-panel {
  position: sticky;
  top: 0;
  display: flex;
  min-width: 0;
  max-height: 100vh;
  align-self: start;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px clamp(20px, 2.6vw, 42px) 12px 0;
  scrollbar-color: rgba(21, 95, 99, .42) rgba(255, 253, 248, .35);
  scrollbar-width: thin;
}
.study-panel::-webkit-scrollbar { width: 8px; }
.study-panel::-webkit-scrollbar-track { background: rgba(255, 253, 248, .35); }
.study-panel::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 999px; background: rgba(21, 95, 99, .42); background-clip: padding-box; }
.dialogue-card { border: 1px solid rgba(96, 87, 77, 0.19); border-radius: 21px; background: rgba(255,253,248,.94); box-shadow: var(--shadow); }

.dialogue-card { overflow: hidden; }
.speaker-header { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 13px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.speaker-avatar { display: block; width: 64px; height: 64px; overflow: hidden; border: 3px solid white; border-radius: 19px 19px 19px 6px; background: var(--teal-soft); box-shadow: 0 5px 15px rgba(42,48,44,.16); }
.speaker-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.speaker-header p { margin-bottom: 2px; color: var(--muted); font-size: 0.56rem; }
.speaker-header strong { font-family: Georgia, "Times New Roman", serif; font-size: 0.95rem; }
.explored-badge { padding: 5px 7px; border-radius: 999px; color: #87650b; background: #fff0c2; font-size: 0.56rem; font-weight: 900; letter-spacing: .08em; }
.explored-badge.complete { color: var(--success); background: #dceee7; }

.japanese-audio { display: flex; width: calc(100% - 28px); min-height: 113px; align-items: center; gap: 11px; margin: 14px; padding: 16px; border: 0; border-radius: 16px; color: white; background: linear-gradient(145deg, var(--coral), var(--coral-dark)); cursor: pointer; box-shadow: 0 12px 28px rgba(183, 67, 55, .25); text-align: left; }
.japanese-audio > span:nth-child(2) { display: grid; min-width: 0; flex: 1; gap: 6px; }
.japanese-audio small { color: rgba(255,255,255,.77); font-size: 0.56rem; font-weight: 850; letter-spacing: .12em; }
.japanese-audio strong { font-family: "Hiragino Sans", "Yu Gothic", sans-serif; font-size: clamp(1.25rem, 1.8vw, 1.75rem); line-height: 1.3; }
.audio-icon { display: grid; width: 31px; height: 31px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: rgba(255,255,255,.18); font-size: .65rem; }
.audio-wave { display: flex; height: 26px; align-items: center; gap: 2px; }
.audio-wave b { width: 2px; height: 9px; border-radius: 3px; background: rgba(255,255,255,.72); }
.audio-wave b:nth-child(2), .audio-wave b:nth-child(4) { height: 18px; }
.audio-wave b:nth-child(3) { height: 25px; }
.japanese-audio.playing .audio-wave b { animation: wave .55s ease-in-out infinite alternate; }
.japanese-audio.playing .audio-wave b:nth-child(2) { animation-delay: -.18s; }
.japanese-audio.playing .audio-wave b:nth-child(3) { animation-delay: -.34s; }
@keyframes wave { to { height: 5px; } }

.playback-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px; }
.playback-row button { min-height: 39px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper-warm); cursor: pointer; font-size: .72rem; font-weight: 800; }
.playback-row button span { margin-right: 5px; color: var(--coral); }
.ai-disclosure { margin: 7px 14px 14px; color: var(--muted); font-size: .59rem; text-align: center; }

.language-details { margin: 0 14px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.language-details > div { padding: 11px 13px; background: white; }
.language-details > div + div { border-top: 1px solid var(--line); }
.language-details dt { margin-bottom: 4px; color: var(--coral-dark); font-size: .55rem; font-weight: 900; letter-spacing: .1em; }
.language-details dd { margin: 0; font-size: .78rem; font-weight: 620; line-height: 1.42; }
.language-details > div:nth-child(n+3) dd { color: var(--muted); font-size: .7rem; font-weight: 500; }

.flashcard-button { width: calc(100% - 28px); min-height: 42px; margin: 12px 14px; border: 1px solid rgba(21,95,99,.22); border-radius: 12px; color: var(--teal); background: var(--teal-soft); cursor: pointer; font-size: .72rem; font-weight: 850; }
.flashcard-button span { margin-right: 5px; font-size: 1rem; }
.flashcard-button.saved { color: white; background: var(--teal); }

.dialogue-navigation { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 11px 14px 14px; border-top: 1px solid var(--line); }
.dialogue-navigation button { padding: 5px 0; border: 0; color: var(--coral-dark); background: transparent; cursor: pointer; font-size: .68rem; font-weight: 800; }
.dialogue-navigation button:last-child { text-align: right; }
.dialogue-navigation button:disabled { opacity: .35; cursor: not-allowed; }
.dialogue-navigation span { color: var(--muted); font-size: .64rem; }

.page-navigation { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: auto; padding-top: 20px; }
.page-navigation button { display: flex; align-items: center; gap: 7px; padding: 8px 0; border: 0; color: var(--teal); background: transparent; cursor: pointer; font-weight: 850; }
.page-navigation button:last-child { justify-content: flex-end; }
.page-navigation button:disabled { opacity: .32; cursor: not-allowed; }
.page-navigation button small { font-size: .59rem; letter-spacing: .08em; }
.page-navigation > span { color: var(--muted); font-size: .66rem; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: min(340px, calc(100% - 32px)); padding: 12px 15px; border-radius: 12px; color: white; background: #262522; box-shadow: 0 12px 32px rgba(0,0,0,.24); font-size: .78rem; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }

body.modal-open { overflow: hidden; }
.flashcard-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(26,25,22,.64); backdrop-filter: blur(10px); }
.flashcard-backdrop[hidden] { display: none; }
.flashcard-library { width: min(1050px, 100%); max-height: min(780px, calc(100vh - 48px)); overflow: auto; border: 1px solid rgba(255,255,255,.42); border-radius: 25px; background: var(--ivory); box-shadow: 0 30px 90px rgba(0,0,0,.32); }
.flashcard-heading { position: sticky; top: 0; z-index: 3; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 24px 28px 20px; border-bottom: 1px solid var(--line); background: rgba(246,240,231,.94); backdrop-filter: blur(16px); }
.flashcard-heading p { margin: 0 0 5px; color: var(--coral-dark); font-size: .61rem; font-weight: 900; letter-spacing: .14em; }
.flashcard-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.7rem,3vw,2.35rem); }
.flashcard-heading div > span { display: block; margin-top: 6px; color: var(--muted); font-size: .72rem; }
.flashcard-heading > button { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); cursor: pointer; font-size: 1.4rem; line-height: 1; }
.flashcard-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 20px; padding: 26px 28px 34px; }
.flashcard-empty { grid-column: 1 / -1; display: grid; min-height: 310px; place-content: center; text-align: center; }
.flashcard-empty > span { color: var(--coral); font-size: 2.6rem; }
.flashcard-empty h3 { margin: 12px 0 5px; font-family: Georgia, serif; font-size: 1.3rem; }
.flashcard-empty p { max-width: 360px; margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.flashcard-item { min-width: 0; }
.flip-card { display: block; width: 100%; height: 360px; padding: 0; border: 0; background: transparent; cursor: pointer; perspective: 1100px; text-align: inherit; }
.flip-card-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 500ms cubic-bezier(.2,.72,.2,1); }
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flashcard-face { position: absolute; inset: 0; display: flex; overflow: hidden; flex-direction: column; align-items: center; padding: 19px; border: 1px solid rgba(96,87,77,.18); border-radius: 20px; backface-visibility: hidden; box-shadow: 0 14px 34px rgba(58,48,39,.13); }
.flashcard-front { background: linear-gradient(155deg, #fffdf8, #f7ebe3); }
.flashcard-back { align-items: stretch; color: white; background: linear-gradient(155deg, var(--teal), #0c4549); transform: rotateY(180deg); }
.card-lesson { width: 100%; color: var(--coral-dark); font-size: .55rem; font-weight: 900; letter-spacing: .1em; text-align: left; }
.flashcard-back .card-lesson { color: rgba(255,255,255,.67); }
.flashcard-front img { width: 96px; height: 96px; margin: 27px 0 11px; border: 4px solid white; border-radius: 50%; object-fit: cover; box-shadow: 0 8px 21px rgba(40,36,30,.16); }
.flashcard-front small { color: var(--muted); font-size: .7rem; font-weight: 800; }
.flashcard-front strong { margin-top: 10px; font-family: "Hiragino Sans", "Yu Gothic", sans-serif; font-size: 1.45rem; line-height: 1.3; text-align: center; }
.flashcard-face > i { margin-top: auto; color: var(--muted); font-size: .62rem; font-style: normal; font-weight: 750; }
.flashcard-back > i { color: rgba(255,255,255,.65); text-align: center; }
.flashcard-back dl { margin: 17px 0 10px; overflow: auto; }
.flashcard-back dl div { padding: 9px 0; border-top: 1px solid rgba(255,255,255,.15); }
.flashcard-back dt { margin-bottom: 3px; color: rgba(255,255,255,.6); font-size: .53rem; font-weight: 900; letter-spacing: .09em; }
.flashcard-back dd { margin: 0; font-size: .72rem; line-height: 1.4; }
.remove-flashcard { display: block; margin: 8px auto 0; padding: 5px 10px; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: .65rem; text-decoration: underline; }

@media (min-width: 961px) {
  .speaker-header { grid-template-columns: 56px 1fr auto; padding: 9px 15px; }
  .speaker-avatar { width: 56px; height: 56px; border-radius: 17px 17px 17px 6px; }
  .japanese-audio { min-height: 94px; margin: 11px 12px; padding: 13px; width: calc(100% - 24px); }
  .japanese-audio strong { font-size: clamp(1.18rem, 1.55vw, 1.55rem); }
  .playback-row { padding: 0 12px; }
  .playback-row button { min-height: 35px; }
  .ai-disclosure { margin: 5px 12px 10px; }
  .language-details { margin: 0 12px; }
  .language-details > div { padding: 8px 11px; }
  .flashcard-button { width: calc(100% - 24px); min-height: 37px; margin: 9px 12px; }
  .dialogue-navigation { padding: 8px 12px 10px; }
  .page-navigation { padding-top: 9px; }
}

@media (max-width: 1180px) {
  .learning-shell { grid-template-columns: 230px minmax(420px, 1.2fr) minmax(310px, .8fr); }
  .lesson-library { padding-left: 22px; }
  .lesson-reader { padding-left: 24px; padding-right: 24px; }
  .study-panel { padding-right: 22px; }
  .library-note { display: none; }
}

@media (max-width: 960px) {
  .learning-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .study-panel { position: static; grid-column: 2; max-height: none; overflow: visible; padding: 0 24px 38px; }
  .page-navigation { margin-top: 0; }
  .flashcard-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 720px) {
  .site-header { min-height: 68px; padding: 10px 15px; }
  .brand small, .header-progress > span, .header-progress > strong { display: none; }
  .header-actions { gap: 9px; }
  .header-progress { grid-template-columns: minmax(95px, 130px); }
  .header-flashcards { font-size: 0; padding-left: 9px; }
  .header-flashcards > span { font-size: .84rem; }
  .learning-shell { display: block; }
  .lesson-library { padding: 24px 15px 15px; border-right: 0; border-bottom: 1px solid var(--line); }
  .library-heading h1 { font-size: 1.55rem; }
  .lesson-list { display: flex; gap: 8px; margin-top: 18px; overflow-x: auto; padding-bottom: 5px; scroll-snap-type: x proximity; }
  .lesson-button { min-width: 205px; flex: 0 0 auto; scroll-snap-align: start; background: rgba(255,255,255,.52); }
  .lesson-reader { padding: 24px 12px 30px; }
  .reader-heading { align-items: flex-start; }
  .reader-heading h2 { font-size: 1.8rem; }
  .progress-pill { margin-top: 21px; }
  .goal-row { margin-top: 12px; }
  .page-strip-wrap { margin-top: 18px; }
  .manga-card { border-radius: 17px; }
  .study-panel { padding: 0 12px 30px; }
  .dialogue-card { border-radius: 17px; }
  .page-navigation { padding: 18px 4px 0; }
  .flashcard-backdrop { padding: 0; }
  .flashcard-library { width: 100%; max-height: 100vh; min-height: 100vh; border-radius: 0; }
  .flashcard-heading { padding: 20px 17px 16px; }
  .flashcard-grid { grid-template-columns: 1fr; padding: 20px 17px 30px; }
  .flip-card { height: 350px; }
}

@media (max-width: 420px) {
  .brand strong { font-size: 1rem; }
  .brand-mark { width: 38px; height: 38px; }
  .manga-meta p { display: none; }
  .page-strip-wrap { grid-template-columns: 27px 1fr 27px; }
  .page-arrow { width: 27px; height: 27px; }
  .page-tab { font-size: .59rem; }
  .japanese-audio { min-height: 103px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
