/* v541: a clear, accessible close cross on every dialog and the mobile menu. */
body dialog :is(button.close,button[aria-label*="fermer" i]):not(.correct):not(.wrong):not(.danger):not(.delete),
body .header #menu.menu.open > #menuCloseButton {
  position: absolute !important;
  top: max(12px, env(safe-area-inset-top)) !important;
  right: 14px !important;
  z-index: 10060 !important;
  display: grid !important;
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  margin: 0 !important;
  padding: 0 !important;
  float: none !important;
  place-items: center !important;
  border: 1px solid #dce3ea !important;
  border-radius: 50% !important;
  background: #fff !important;
  background-image: none !important;
  color: #40566d !important;
  -webkit-text-fill-color: #40566d !important;
  font: 700 29px/1 Arial, sans-serif !important;
  text-shadow: none !important;
  box-shadow: 0 2px 8px rgba(31,49,54,.15) !important;
  opacity: 1 !important;
  cursor: pointer !important;
}
body dialog :is(button.close,button[aria-label*="fermer" i])::first-line,
body .header #menu.menu.open > #menuCloseButton::first-line {
  color: #40566d !important;
  -webkit-text-fill-color: #40566d !important;
}
body dialog :is(button.close,button[aria-label*="fermer" i]):not(.correct):not(.wrong):not(.danger):not(.delete):hover,
body dialog :is(button.close,button[aria-label*="fermer" i]):not(.correct):not(.wrong):not(.danger):not(.delete):focus-visible,
body .header #menu.menu.open > #menuCloseButton:hover,
body .header #menu.menu.open > #menuCloseButton:focus-visible {
  border-color: #496b8b !important;
  background: #edf2f7 !important;
  color: #263645 !important;
  -webkit-text-fill-color: #263645 !important;
  outline: 3px solid rgba(73,107,139,.2) !important;
  outline-offset: 2px !important;
}

/* Give the close control its own top-right space so it never covers headings. */
body dialog :is(.pricing-content,.referral-content,.information-content,.install-help-content,.signup-content,.parent-content,.pack-content,.profile-content,.student-space-content,.student-dialog-content,.expose-content,.learning-dialog-content,.orthography-content,.reading-content,.dictation-content,.dictation-shell,.tables-content,.sports-quiz-content,.culture-quiz-content,.school-quiz-content,.vario-adventure-content,.script-writing-content,.irregular-content) {
  position: relative !important;
}
body #pricingDialog { position: fixed !important; }
body #pricingDialog .pricing-close {
  position: absolute !important;
  top: max(12px, env(safe-area-inset-top)) !important;
  right: 14px !important;
  margin: 0 !important;
}
body .header #menu.menu.open { position: fixed !important; }
body .header #menu.menu.open > #menuCloseButton {
  position: fixed !important;
  top: max(12px, env(safe-area-inset-top)) !important;
  right: 16px !important;
}
body .header #menu.menu.open::before { padding-right: 58px !important; }
body dialog :is(.pricing-content,.referral-content,.information-content,.install-help-content,.signup-content,.parent-content,.pack-content,.profile-content,.student-space-content,.student-dialog-content,.expose-content,.learning-dialog-content,.orthography-content,.reading-content,.dictation-content,.dictation-shell,.tables-content,.sports-quiz-content,.culture-quiz-content,.school-quiz-content,.vario-adventure-content,.script-writing-content,.irregular-content) > :is(h1,h2,.lesson-label) {
  padding-right: 56px !important;
}
body #pricingDialog .pricing-heading { padding-right: 54px !important; }
body #pricingDialog .pricing-content > .lesson-label { display: inline-block !important; max-width: calc(100% - 58px) !important; }
body #informationDialog .information-content > section > h2 { padding-right: 56px !important; }
/* The legal dialog's long pre-launch label must wrap before reaching the close button. */
body #informationDialog .information-content > section > .lesson-label {
  display: block !important;
  width: calc(100% - 62px) !important;
  max-width: calc(100% - 62px) !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  line-height: 1.2 !important;
}

/* Keep the mobile menu heading and close control in a dedicated sticky header. */
@media (max-width: 900px) {
  body .header #menu.menu.open::before {
    position: sticky !important;
    top: 0 !important;
    z-index: 10050 !important;
    width: 100% !important;
    min-height: 54px !important;
    box-sizing: border-box !important;
    padding: 6px 62px 12px 2px !important;
    background: #fff !important;
  }
  body .header #menu.menu.open > button.menu-parent-access,
  body .header #menu.menu.open > button.menu-install {
    border-color: #dce3ea !important;
    background: #edf2f7 !important;
    color: #40566d !important;
    -webkit-text-fill-color: #40566d !important;
  }
  body .header #menu.menu.open > button.menu-parent-access > .parent-mark {
    border-color: #496b8b !important;
    background: #496b8b !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
  }
  body .header #menu.menu.open > button.menu-install > span {
    border-radius: 9px !important;
    background: #dce3ea !important;
    color: #40566d !important;
    -webkit-text-fill-color: #40566d !important;
  }
  body .header #menu.menu.open .menu-account:not([hidden]),
  body .header #menu.menu.open .clerk-mobile-account:not([hidden]) {
    border-top: 1px solid #dce3ea !important;
    padding-top: 14px !important;
    margin-top: 6px !important;
  }
}

/* Leave a clear header band above the control-tomorrow dialog content. */
body #controlTomorrowForm {
  padding-top: 82px !important;
}

/* Make the chosen mental-math operation unmistakable. */
#tablesDialog .operation-picker > button:not(.selected) {
  border: 2px solid #dce3ea !important;
  background: #f7f9fb !important;
  color: #40566d !important;
  -webkit-text-fill-color: #40566d !important;
  box-shadow: none !important;
  outline: none !important;
  transform: none !important;
}
#tablesDialog .operation-picker > button.selected,
#tablesDialog .operation-picker > button.selected:focus,
#tablesDialog .operation-picker > button.selected:focus-visible {
  position: relative !important;
  border: 3px solid #263645 !important;
  background: #496b8b !important;
  background-image: none !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  box-shadow: 0 0 0 4px rgba(73,107,139,.24), inset 0 -4px 0 #263645 !important;
  outline: none !important;
  transform: translateY(-2px) !important;
}
#tablesDialog .operation-picker > button.selected::after {
  content: "✓" !important;
  position: absolute !important;
  top: 5px !important;
  right: 7px !important;
  display: grid !important;
  width: 22px !important;
  height: 22px !important;
  place-items: center !important;
  border-radius: 50% !important;
  background: #fff !important;
  color: #263645 !important;
  -webkit-text-fill-color: #263645 !important;
  font: 900 14px/1 Arial,sans-serif !important;
}
#tablesDialog .operation-picker > button.selected :is(span,strong) {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

/* Poetry uses a longer close label; give its modal the same neutral surface. */
body dialog.poetry-dialog .poetry-dialog-card {
  border-color: #dce3ea !important;
  background: #fff !important;
  color: #263645 !important;
}
body dialog.poetry-dialog .poetry-dialog-card button.poetry-close:not(.correct):not(.wrong):not(.danger):not(.delete) {
  border: 1px solid #dce3ea !important;
  border-radius: 50% !important;
  background: #fff !important;
  color: #40566d !important;
  -webkit-text-fill-color: #40566d !important;
  box-shadow: 0 2px 8px rgba(31,49,54,.15) !important;
}
body dialog.poetry-dialog .poetry-dialog-card h2 { color: #263645 !important; }
body dialog.poetry-dialog .poetry-dialog-card h2::after { background: #496b8b !important; }
body dialog.poetry-dialog .poetry-dialog-card :is(.poetry-line,.poetry-upload,#checkPoetryLine) {
  border-color: #dce3ea !important; background: #edf2f7 !important; color: #40566d !important;
  box-shadow: none !important;
}
