/* Keyboard shortcuts and study guide */
.header-help{
  display:flex;
  align-items:center;
  gap:4px;
  flex:none
}

.header-help button{
  width:40px;
  min-height:44px;
  padding:0;
  background:transparent;
  color:var(--muted)
}

.header-help button:hover{
  color:var(--accent)
}

.header-help .ui-icon{
  width:19px;
  height:19px
}

@media(max-width:480px){
  .header-actions{
    display:flex;
    grid-column:2;
    grid-row:1;
    gap:5px;
    align-items:center
  }
  .header-help{
    gap:3px
  }
  .header-help button{
    width:36px;
    min-height:44px
  }
  .header-actions .language{
    width:112px
  }
  .header-actions #language{
    font-size:13px
  }
  .brand{
    min-width:0
  }
  .eyebrow{
    overflow-wrap:anywhere
  }
  .brandmark{
    display:none
  }
}

@media(max-width:360px){
  .header-actions .language{
    width:99px
  }
  .header-actions #language{
    padding-left:22px;
    padding-right:18px
  }
  .header-actions .language-control>.ui-icon{
    left:4px;
    width:13px
  }
  .header-help button{
    width:32px
  }
  .header-help .ui-icon{
    width:17px;
    height:17px
  }
  .brand h1{
    font-size:22px
  }
  .eyebrow{
    font-size:8px
  }
}

.help-dialog{
  width:min(520px,calc(100% - 24px));
  max-height:min(82vh,700px);
  max-height:min(82dvh,700px);
  overflow:auto;
  background:var(--panel);
  color:var(--text);
  border:1px solid var(--line);
  border-radius:12px;
  padding:0;
  box-shadow:0 14px 48px #0004
}

.help-dialog::backdrop{
  background:#0008
}

.help-head{
  position:sticky;
  top:0;
  background:var(--panel);
  padding:14px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  border-bottom:1px solid var(--line);
  z-index:1
}

.help-head h2{
  font-size:18px;
  margin:0
}

.help-head button{
  width:44px;
  flex:none;
  padding:0
}

.help-body{
  padding:16px 18px 20px
}

.help-body p{
  margin:0 0 14px;
  color:var(--muted);
  font-size:13px;
  line-height:1.6
}

.help-body h3{
  font-size:14px;
  margin:18px 0 8px
}

.help-steps{
  margin:0;
  padding:0;
  list-style:none;
  counter-reset:step
}

.help-steps li{
  counter-increment:step;
  display:grid;
  grid-template-columns:28px minmax(0,1fr);
  gap:10px;
  padding:11px 0;
  border-bottom:1px solid var(--line)
}

.help-steps li::before{
  content:counter(step,decimal-leading-zero);
  color:var(--accent);
  font-weight:700;
  font-size:12px;
  margin-top:2px
}

.help-steps strong{
  display:block;
  font-size:14px
}

.help-steps p{
  margin:4px 0 0
}

.shortcut-list{
  margin:0
}

.shortcut-list>div{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:8px;
  padding:9px 0;
  border-bottom:1px solid var(--line)
}

.shortcut-list dt{
  font-size:13px
}

.shortcut-list dd{
  margin:0;
  text-align:right
}

.shortcut-list kbd{
  font:600 12px/1.4 system-ui,sans-serif;
  display:inline-block;
  border:1px solid var(--line);
  background:var(--soft);
  border-radius:5px;
  padding:3px 7px;
  white-space:normal;
  max-width:180px
}

.shortcut-toggle{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin:0 0 12px;
  color:var(--text);
  font-size:14px
}

.shortcut-toggle input{
  width:20px;
  height:20px;
  min-height:0;
  accent-color:var(--accent);
  flex:none
}

.help-note{
  margin-top:14px!important
}

/* Study mode is independent of playback mode. */
.study-mode{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:4px;
  background:var(--soft);
  border:1px solid var(--line);
  padding:4px;
  border-radius:9px;
  margin-bottom:18px
}

.study-mode button{
  min-height:42px;
  border:1px solid transparent;
  background:transparent;
  color:var(--muted);
  font-size:13px;
  padding:8px 6px;
  border-radius:6px;
  line-height:1.35
}

.study-mode button[aria-pressed="true"]{
  background:var(--panel);
  border-color:var(--line);
  color:var(--accent);
  box-shadow:0 1px 3px #00000012
}

.study-mode button[aria-pressed="true"]:hover{
  background:var(--panel)
}

.study-mode .ui-icon{
  width:16px;
  height:16px
}

.memorize-heading{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
  flex-wrap:wrap
}

.memorize-heading h2{
  margin:0;
  color:var(--muted);
  font-size:12px
}

.memorize-heading button{
  font-size:12px;
  color:var(--muted);
  border:0;
  background:transparent;
  min-height:44px;
  padding:4px 8px
}

.question-panel:is([data-study-mode="memorize"],[data-study-mode="typing"]) .answer{
  display:flex;
  flex-direction:column;
  margin-top:18px
}

.question-panel:is([data-study-mode="memorize"],[data-study-mode="typing"]) #answer{
  order:0;
  border:0;
  padding:0 0 18px;
  margin:0
}

.question-panel:is([data-study-mode="memorize"],[data-study-mode="typing"]) .utility{
  order:1;
  grid-template-columns:minmax(0,1fr)
}

.question-panel:is([data-study-mode="memorize"],[data-study-mode="typing"]) #mark{
  background:var(--solid);
  color:#fff;
  border-color:var(--solid);
  min-height:44px;
  font-size:14px
}

.question-panel:is([data-study-mode="memorize"],[data-study-mode="typing"]) #mark[aria-pressed="true"]{
  background:var(--success-bg);
  color:var(--success);
  border-color:var(--success)
}

.question-panel:is([data-study-mode="memorize"],[data-study-mode="typing"]) #english{
  font-size:clamp(20px,3vw,25px);
  line-height:1.65
}

.question-panel [hidden]{
  display:none!important
}

@media(max-width:760px){
  .study-mode{
    margin-bottom:12px
  }
  .study-mode button{
    font-size:12px
  }
  .question-panel:is([data-study-mode="memorize"],[data-study-mode="typing"]) .answer{
    margin-top:12px
  }
}

.dictation-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:8px
}

.dictation-head h2{
  margin:0
}

.dictation-head button{
  min-height:36px;
  padding:6px 10px;
  font-size:12px;
  color:var(--accent);
  background:transparent
}

.dictation-hint{
  font-size:12px;
  line-height:1.5;
  color:var(--muted);
  margin:0 0 10px;
  overflow-wrap:anywhere
}

/* Word-level dictation feedback */
#result:not(:empty){
  padding:14px;
  border:1px solid var(--line);
  border-radius:8px;
  background:var(--soft);
  white-space:normal;
  line-height:1.65
}

#result .grade-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:10px
}

#result .grade-score{
  font-size:22px;
  font-weight:750;
  line-height:1.2;
  color:var(--text);
  font-variant-numeric:tabular-nums
}

#result .grade-label,#result .grade-note{
  font-size:11px;
  color:var(--muted);
  font-weight:500
}

#result .grade-perfect{
  color:var(--success);
  font-weight:650
}

#result .grade-words{
  font-size:16px;
  line-height:2;
  overflow-wrap:anywhere;
  color:var(--text)
}

#result .grade-correct{
  color:var(--success);
  font-weight:650
}

#result .grade-missing{
  color:var(--grade-error);
  font-weight:650;
  text-decoration:underline dotted;
  text-underline-offset:3px
}

#result .grade-extra{
  color:var(--grade-error);
  text-decoration:line-through;
  text-decoration-thickness:1.5px
}

#result .grade-legend{
  display:flex;
  flex-wrap:wrap;
  gap:4px 13px;
  margin-top:10px;
  font-size:11px;
  align-items:center
}

#result .grade-legend span{
  white-space:normal
}

#result .grade-note{
  margin-top:8px
}

:root{
  --grade-error:#a82b36
}

@media(prefers-color-scheme:dark){
  :root{
    --grade-error:#ff9ba5
  }
}

/* Tap a word to hear the corresponding part of the original recording. */
#english .word-audio,#result .word-audio{
  display:inline;
  min-height:0;
  padding:0 1px;
  margin:0;
  border:0;
  border-radius:3px;
  background:transparent;
  line-height:inherit;
  font:inherit;
  letter-spacing:inherit;
  color:inherit;
  vertical-align:baseline;
  cursor:pointer;
  text-align:left;
  overflow-wrap:anywhere
}

#english .word-audio{
  color:var(--text)
}

#english .word-audio.spoken,#english .word-audio.current{
  color:var(--accent)
}

#result .word-audio.grade-correct{
  color:var(--success);
  font-weight:650
}

#result .word-audio.grade-missing{
  color:var(--grade-error);
  font-weight:650;
  text-decoration:underline dotted;
  text-underline-offset:3px
}

#english .word-audio:hover,#result .word-audio:hover,#english .word-audio.clip-active,#result .word-audio.clip-active{
  background:var(--panel);
  box-shadow:0 2px 0 currentColor
}

#english .word-audio.clip-active,#result .word-audio.clip-active{
  outline:1px solid var(--accent);
  outline-offset:2px
}

.word-audio-hint{
  font-size:11px;
  color:var(--muted);
  margin:8px 0 0;
  line-height:1.5;
  display:flex;
  gap:5px;
  align-items:center
}

.word-audio-hint svg{
  width:14px;
  height:14px;
  flex:none
}

.study-tools{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin:-8px 0 18px
}

.study-tools button{
  background:transparent;
  border:1px solid var(--line);
  font-size:12px;
  min-height:40px;
  color:var(--muted);
  padding:7px 9px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  white-space:normal
}

.study-tools button:hover{
  color:var(--accent)
}

.review-count{
  background:var(--soft);
  color:var(--accent);
  font-size:11px;
  padding:1px 6px;
  border-radius:10px
}

.review-session{
  display:flex;
  align-items:center;
  gap:7px;
  padding:8px 0 12px;
  color:var(--accent);
  font-size:12px;
  flex-wrap:wrap
}

.review-session span{
  flex:1
}

.review-session button{
  min-height:36px;
  font-size:12px;
  padding:5px 9px
}

.attempt-summary{
  font-size:11px;
  color:var(--muted);
  margin-top:8px
}

.plus-dialog{
  width:min(590px,calc(100% - 24px));
  max-height:85vh;
  max-height:85dvh;
  overflow:auto;
  background:var(--panel);
  color:var(--text);
  border:1px solid var(--line);
  border-radius:12px;
  padding:18px
}

.plus-dialog::backdrop{
  background:#0008
}

#examDialog::backdrop{
  background:var(--bg);
  opacity:1
}

.plus-dialog h2{
  font-size:18px;
  margin:0
}

.plus-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  border-bottom:1px solid var(--line);
  padding-bottom:10px;
  margin-bottom:14px
}

.plus-head button{
  min-height:40px;
  min-width:40px;
  font-size:20px;
  background:transparent;
  color:var(--muted);
  padding:4px
}

.plus-tabs{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:4px;
  background:var(--soft);
  padding:4px;
  border-radius:8px;
  margin:12px 0
}

.plus-tabs button{
  min-height:40px;
  font-size:11px;
  padding:4px;
  background:transparent;
  color:var(--muted);
  border:1px solid transparent;
  white-space:normal;
  overflow-wrap:anywhere
}

.plus-tabs button[aria-pressed=true]{
  background:var(--panel);
  color:var(--accent);
  border-color:var(--line)
}

.plus-summary{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:8px;
  margin:0 0 12px
}

.plus-stat{
  border:1px solid var(--line);
  border-radius:8px;
  padding:10px;
  min-width:0
}

.plus-stat strong{
  display:block;
  font-size:22px;
  color:var(--accent)
}

.plus-stat small{
  font-size:11px;
  color:var(--muted);
  overflow-wrap:anywhere
}

.plus-list{
  display:grid;
  gap:0;
  margin-top:12px
}

.plus-item{
  padding:11px 0;
  border-bottom:1px solid var(--line);
  display:flex;
  gap:8px;
  align-items:center;
  justify-content:space-between
}

.plus-item>div{
  min-width:0;
  flex:1;
  overflow-wrap:anywhere
}

.plus-item small,.plus-note{
  display:block;
  color:var(--muted);
  font-size:12px;
  line-height:1.5
}

.plus-item button{
  min-height:36px;
  flex:none;
  font-size:12px;
  padding:5px 9px
}

.plus-action{
  width:100%;
  margin-top:12px;
  background:var(--solid);
  color:white;
  border-color:var(--solid);
  min-height:44px
}

.plus-dialog textarea{
  width:100%;
  min-height:115px;
  font:inherit;
  font-size:16px;
  padding:12px;
  margin:12px 0 0;
  resize:vertical;
  background:var(--bg);
  color:var(--text);
  border:1px solid var(--line);
  border-radius:8px
}

.exam-status{
  padding:14px;
  border:1px solid var(--line);
  border-radius:8px;
  margin:12px 0;
  color:var(--accent);
  font-weight:650
}

.exam-answer{
  margin-top:12px;
  padding:12px;
  border:1px solid var(--line);
  border-radius:8px;
  overflow-wrap:anywhere
}

.exam-answer .bad{
  color:var(--grade-error)
}

.exam-answer .good{
  color:var(--success)
}

.exam-answer p{
  margin:5px 0
}

.exam-score{
  font-size:28px;
  font-weight:750;
  color:var(--accent)
}

.plus-reset{
  display:block;
  width:100%;
  margin-top:18px;
  padding:10px 12px;
  min-height:42px;
  background:transparent;
  color:var(--grade-error);
  border:1px solid var(--line);
  font-size:12px;
  white-space:normal
}

.plus-reset:hover{
  border-color:var(--grade-error)
}

.plus-dialog [hidden]{
  display:none!important
}

@media(max-width:480px){
  .study-tools{
    margin:-4px 0 12px
  }
  .plus-dialog{
    padding:14px
  }
  .plus-tabs button{
    font-size:10px
  }
  .plus-stat{
    padding:7px
  }
  .plus-stat strong{
    font-size:19px
  }
}

/* Typing shares the existing question panel, transcript, input and progress styles. */
.study-mode button { min-width:0; overflow-wrap:anywhere; white-space:normal; }


.question-panel[data-study-mode="typing"] #english { font-size:clamp(20px,3vw,25px); line-height:1.65; }
#english [data-typing-state="correct"] { color:var(--success); }
#english [data-typing-state="incorrect"] { color:var(--grade-error); text-decoration:underline dotted; text-underline-offset:3px; }
#typingArea { margin-top:16px; }
#typingCount { font-size:12px; text-align:right; font-variant-numeric:tabular-nums; }
#typingProgress { width:100%; }
.typing-hint { font-size:12px; margin:8px 0; line-height:1.5; }
#typingInput { min-height:100px; }
#typingInput[aria-invalid="true"] { border-color:var(--grade-error); }
.typing-meta { justify-content:space-between; gap:8px; min-height:18px; }
#typingFeedback { overflow-wrap:anywhere; }
#typingLength { white-space:nowrap; }
.typing-settings { margin-top:8px; }
.typing-settings .settings { grid-template-columns:1fr; }

