*{box-sizing:border-box}html{background:#f1f0f4;color:#212022;font:16px/1.5 "DM Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}body{margin:0 auto;background:#fbfaf9;min-height:100vh;max-width:740px;padding:0 clamp(16px,4vw,35px) 110px}header{padding:23px 0 20px}.brand{font-weight:750;font-size:19px;display:flex;align-items:center;gap:10px}.brand b{border-radius:11px;background:#242329;color:#fff;padding:4px 9px;font-size:20px;font-style:italic}h1,h2,p{margin:0 0 12px}h1{font-size:clamp(27px,5vw,43px);line-height:1.04;letter-spacing:-.055em;max-width:76%;position:relative;text-wrap:balance}h2{font-size:21px;line-height:1.2;letter-spacing:-.035em}.hero{position:relative;isolation:isolate;overflow:hidden;border-radius:28px;background:linear-gradient(118deg,#bde1d4,#e4edba 80%,#fae8b9);padding:25px 22px 23px;min-height:162px}.hero.pink{background:linear-gradient(116deg,#ffdded,#f2d7ed 70%,#dbcdfb)}.hero p{max-width:68%;position:relative;margin:8px 0 0}.hero small,.scene>small{display:block;margin:0 0 12px;font-size:13px;font-weight:650}.art{position:absolute;right:6%;bottom:20%;width:90px;height:60px;transform:rotate(-10deg);z-index:-1}.art i,.art b{position:absolute;border-radius:13px;padding:5px 13px;box-shadow:1px 5px 0 #75648766,0 9px 13px #715b7330;font-weight:850}.art i{background:linear-gradient(150deg,#fff,#f0dbf8);font-style:normal;font-size:22px;right:0;top:0;transform:rotate(17deg)}.art b{background:linear-gradient(135deg,#b7a3f6,#8667d9);top:31px;left:0;color:white}.btn,button{background:#262429;color:#fff;border:0;border-radius:100px;text-decoration:none;font:inherit;font-weight:650;padding:11px 18px;display:inline-block;cursor:pointer}a{color:inherit}.sectionTitle,.row,.wrap{display:flex;align-items:center;gap:12px}.sectionTitle{justify-content:space-between;margin:24px 2px 12px}.sectionTitle h2{margin:0}.sectionTitle span,.note,.row small,footer{font-size:14px;color:#595563}.list,.wrap{display:grid;gap:10px}.row,article{background:#fff;border:1px solid #e8e5e8;border-radius:23px}.row{padding:14px;text-decoration:none}.row strong,.row small,.pair strong,.pair span,.phon{display:block}.row em{margin-left:auto;font-size:13px;font-style:normal}.icon{width:44px;height:44px;border-radius:16px;display:grid;place-items:center;flex:none}.color0,.scene{background:#f0e9fb}.color1{background:#dff0e9}.color2{background:#ffdfeb}.note{margin:16px 0}article{padding:clamp(17px,4vw,26px);margin:16px 0}.pair{border-top:1px solid #ece9eb;padding:14px 0;min-height:70px}.pair strong{font-size:19px}.phon{font-size:13px;color:#675e70;font-style:italic;margin:1px 0 4px}.sound{float:right;margin-left:8px;width:40px;height:40px;padding:0;background:#f0ebf8;color:#352e43;font-size:22px}details{margin:12px 0}summary{cursor:pointer;font-weight:650}blockquote{margin:12px 0;border-left:3px solid #c5addb;padding-left:12px}fieldset{min-width:0;border:0;padding:0;margin:17px 0}legend{font-weight:700}label{display:block;background:#f4f2f5;border-radius:13px;padding:11px;margin:7px 0}input{accent-color:#59457a}.feedback{padding:8px;background:#e5f3df}footer{margin:24px 0}.wrap{display:flex;flex-wrap:wrap}.quiet{background:#eeeaf2;color:#252128}:focus-visible{outline:3px solid #8560ba;outline-offset:3px}@media(max-width:420px){.art{right:4%;transform:scale(.78) rotate(-10deg);transform-origin:right}.hero{padding:22px 16px}h1{max-width:72%}.row{padding:12px;gap:9px}}

.grammar-feedback:not(:empty){margin-top:8px;padding:8px 11px;background:#e5f3df;border-radius:10px}

[hidden]{display:none!important}
nav{
  position:fixed;z-index:4;left:50%;transform:translateX(-50%);
  bottom:max(12px,env(safe-area-inset-bottom));display:flex;gap:7px;
  padding:7px;border-radius:24px;background:#fffffff0;
  border:1px solid #e6e0e9;box-shadow:0 10px 36px #28222f22;
  -webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px)
}
nav a{
  display:grid;place-items:center;width:56px;height:48px;border-radius:17px;
  color:#554b60;transition:background-color .15s,color .15s
}
nav a:hover{background:#f0e9fb}
nav a[aria-current="page"]{background:#30283a;color:#fff}
nav svg,.lock-icon{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.locked-lesson{background:#f5f2f6;border-color:#ebe6ed;color:#62596a}
.locked-lesson .icon{background:#ece6ef;color:#655c6c}
.lock-icon{width:19px;height:19px;margin-inline-start:auto;flex:none}
.row em{flex-shrink:0}
#save-notice{
  position:fixed;z-index:3;left:50%;transform:translateX(-50%);
  bottom:calc(max(12px,env(safe-area-inset-bottom)) + 72px);
  width:min(calc(100% - 32px),480px);margin:0;padding:10px 14px;
  background:#fff7e9;border:1px solid #eddabb;border-radius:18px;
  box-shadow:0 5px 18px #28222f14
}
#retry-save{margin:3px 0;padding:7px 12px}

.chapter-controls{
  display:flex;align-items:center;justify-content:space-between;
  margin:0 0 12px;color:#554b60;font-size:14px;font-weight:700
}
.chapter-controls button{
  display:grid;place-items:center;width:44px;height:44px;padding:0;
  border:1px solid #e6e0e9;border-radius:15px;background:#fff;color:#30283a
}
.chapter-controls button:disabled{opacity:.38;cursor:default}
.chapter-controls svg{
  width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;
  stroke-linecap:round;stroke-linejoin:round
}
.course-list{
  display:flex;align-items:flex-start;overflow-x:auto;overscroll-behavior-x:contain;
  scroll-snap-type:x mandatory;scrollbar-width:none
}
.course-list::-webkit-scrollbar{display:none}
.lesson-group{flex:0 0 100%;min-width:0;scroll-snap-align:start;scroll-snap-stop:always}

/* Only the lesson rows scroll vertically on the chapter overview. */
html:has(#chapter-pages){overflow:hidden}
body:has(#chapter-pages){
  display:flex;flex-direction:column;min-height:0;
  height:100vh;height:100dvh;
  padding-bottom:calc(76px + max(12px,env(safe-area-inset-bottom)));
  overflow:hidden
}
body:has(#chapter-pages)>header{flex:none}
#app:has(#chapter-pages){
  flex:1;display:flex;flex-direction:column;min-height:0
}
#app:has(#chapter-pages) .chapter-controls{flex:none}
#chapter-pages{flex:1;min-height:0;align-items:stretch;overflow-y:hidden}
#chapter-pages .lesson-group{
  display:flex;flex-direction:column;min-height:0;overflow:hidden
}
#chapter-pages .hero{flex:none;margin-bottom:16px}
.chapter-lessons{
  flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
  align-content:start;overscroll-behavior-y:contain;
  padding:2px 3px 12px
}
.chapter-lessons:focus-visible{outline-offset:-3px;border-radius:12px}

@media(max-height:700px){
  body:has(#chapter-pages)>header{padding-block:10px}
  #chapter-pages .hero{min-height:0;padding-block:14px}
  #chapter-pages .hero small{margin-bottom:5px}
  #chapter-pages h1{font-size:clamp(22px,5vw,32px);margin-bottom:4px}
  #chapter-pages .hero p:empty{display:none}
}

@media(max-height:440px){
  body:has(#chapter-pages)>header{padding-block:4px}
  body:has(#chapter-pages) .brand{font-size:15px}
  #app:has(#chapter-pages) .chapter-controls{margin-bottom:4px}
  #chapter-pages .hero{padding-block:8px}
}

/* Keep chapter banners the same size within each viewport and scroll state. */
#chapter-pages .hero{
  height:clamp(164px,26dvh,224px);
  display:flex;flex-direction:column;justify-content:center;
  transition:height .18s ease
}
#chapter-pages .hero p:empty{display:none}
#chapter-pages .chapter-compact .hero{
  height:84px;padding-block:8px;margin-bottom:10px
}
#chapter-pages .chapter-compact .hero small{margin-bottom:4px;font-size:12px}
#chapter-pages .chapter-compact .hero h1{
  max-width:none;margin:0;font-size:clamp(19px,4vw,25px);
  line-height:1.12;text-wrap:wrap
}
#chapter-pages .chapter-compact .hero p,
#chapter-pages .chapter-compact .hero .art{display:none}

@media(max-height:540px){
  #chapter-pages .hero{height:142px}
  #chapter-pages .chapter-compact .hero{height:70px}
}

@media(prefers-reduced-motion:reduce){
  #chapter-pages .hero{transition:none}
}

.vocabulary-heading{display:flex;align-items:baseline;justify-content:space-between;gap:12px;margin-bottom:14px}
.vocabulary-heading h2{margin:0}
.vocabulary-count{color:#655b70;font-size:.875rem;font-variant-numeric:tabular-nums;white-space:nowrap}
.vocabulary-card{display:flex;align-items:center;gap:clamp(10px,3vw,20px);min-height:128px;padding:clamp(12px,3vw,19px);border:1px solid #ece3f7;border-radius:18px;background:#f9f5fd}
.vocabulary-word{flex:1;min-width:0}
.vocabulary-word .pair{border:0;padding:0;min-height:0;overflow-wrap:anywhere}
.vocabulary-word strong{font-size:clamp(1.25rem,4vw,1.65rem);line-height:1.25}
.vocabulary-word .phon{font-size:.875rem}
.vocabulary-word .sound{background:#eee5f8}
.vocabulary-mascot{flex:0 0 clamp(54px,16vw,96px)}
.vocabulary-mascot[hidden]{display:none}
.vocabulary-mascot img{display:block;width:100%;height:auto;aspect-ratio:1;object-fit:contain}
.vocabulary-next{margin-top:14px;min-height:44px}
#vocabulary-cards,#lesson-tasks,.scene{scroll-margin-top:16px}
#completion[hidden]{display:none}
.lesson-task-next{min-height:44px}
.lesson-quiz-feedback:not(:empty){margin:14px 0}
@media(max-width:420px){.vocabulary-next{width:100%}}

.flashcard-exit{display:none}
.flashcard-stage{position:relative;display:grid;margin-bottom:16px;min-width:0}
.flashcard-toggle{display:grid;grid-template-rows:1fr auto;gap:10px;width:100%;min-height:210px;padding:0 0 14px;
  background:#f6f0fc;color:#30283a;border:1px solid #e9dcf5;border-radius:24px;perspective:1000px;touch-action:manipulation}
.flashcard-sides{display:grid;transform-style:preserve-3d;transition:transform .35s ease}
.flashcard-toggle.is-flipped .flashcard-sides{transform:rotateY(180deg)}
.flashcard-face{display:grid;grid-area:1/1;align-content:center;justify-items:center;gap:10px;padding:30px 18px 10px;backface-visibility:hidden}
.flashcard-back{transform:rotateY(180deg)}
.flashcard-face strong{font-size:clamp(1.6rem,6vw,2.65rem);line-height:1.15;overflow-wrap:anywhere;text-wrap:balance}
.flashcard-face small,#flashcard-hint{font-size:.875rem;color:#655673}
.flashcard-face .phon{font-size:1rem}
.flashcard-audio{position:absolute;top:12px;right:12px;width:44px;height:44px}
.flashcard-audio[hidden]{display:none}
@media(prefers-reduced-motion:reduce){.flashcard-sides{transition:none}}

@media(max-width:640px), (pointer:coarse) and (max-height:500px){
  body:has(.lesson-flashcards){overflow:hidden}
  body:has(.lesson-flashcards) > :is(header, nav, .five-mascot-root),
  #app:has(.lesson-flashcards) > .hero{display:none}
  #lesson-tasks.lesson-flashcards{
    position:fixed;inset:0;z-index:10;display:flex;flex-direction:column;overflow:auto;
    margin:0;border:0;border-radius:0;background:#fbfaf9;
    padding:max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right))
      max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left))
  }
  .lesson-flashcards .vocabulary-heading{align-items:center;flex-wrap:wrap;margin-bottom:8px}
  .lesson-flashcards .vocabulary-heading h2{flex:1 1 140px}
  .flashcard-exit{display:inline-flex;min-height:44px;align-items:center;padding:0 10px;
    border-radius:12px;background:#eeeaf2;font-weight:650}
  .flashcard-stage{flex:1 0 auto}
  .flashcard-toggle{min-height:170px}
  .lesson-flashcards .lesson-task-next{width:100%;flex:none}
  .lesson-flashcards details{margin:0 0 12px}
}
