.language-pending main { visibility: hidden; }
.language-load-failed main { visibility: hidden; }
.site-loading { display: none; }
.language-pending.loading-slow .site-loading,
.language-load-failed .site-loading {
  display: grid;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
  color: #f7fbff;
}
.site-loading-skeleton { display: grid; gap: 10px; width: min(260px, 100%); margin-bottom: 8px; }
.site-loading-skeleton span {
  display: block;
  height: 44px;
  border: 1px solid rgba(190,233,255,.2);
  border-radius: 8px;
  background: linear-gradient(100deg, rgba(255,255,255,.05) 20%, rgba(255,255,255,.12) 50%, rgba(255,255,255,.05) 80%);
  background-size: 200% 100%;
  animation: loading-shimmer 2.4s ease-in-out infinite;
}
.site-loading-copy h2 { margin: 0; font: inherit; font-size: 1.1rem; font-weight: 750; line-height: 1.4; }
.site-loading-copy p { margin: 7px 0 0; color: #bac9da; font-size: .9rem; line-height: 1.6; }
.site-loading-copy { max-width: 320px; }
.site-loading [lang="en"],
html[lang="en"] .site-loading [lang="zh-CN"] { display: none; }
html[lang="en"] .site-loading [lang="en"] { display: block; }
.site-loading .loading-slow-copy,
.site-loading .loading-error-copy,
.site-loading-retry { display: none; }
.loading-slow .site-loading .loading-normal,
.language-load-failed .site-loading .loading-normal,
.language-load-failed .site-loading-dots { display: none; }
.loading-slow .site-loading .loading-slow-copy,
.language-load-failed .site-loading .loading-error-copy { display: block; }
.loading-slow .site-loading-retry,
.language-load-failed .site-loading-retry {
  display: block;
  pointer-events: auto;
  min-height: 44px;
  padding: 8px 16px;
  margin-top: 4px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(190,233,255,.4);
  border-radius: 8px;
  color: inherit;
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}
.site-loading-retry:focus-visible { outline: 3px solid #8edff0; outline-offset: 3px; }
.site-loading-dots { display: flex; gap: 7px; margin-top: 2px; }
.site-loading-dots span { width: 5px; height: 5px; border-radius: 50%; background: #8edff0; animation: loading-pulse 1.4s ease-in-out infinite; }
.site-loading-dots span:nth-child(2) { animation-delay: .18s; }
.site-loading-dots span:nth-child(3) { animation-delay: .36s; }
.language-load-failed .site-loading-skeleton { display: none; }
@keyframes loading-shimmer { 50% { background-position: 100% 0; } }
@keyframes loading-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) {
  .site-loading-skeleton span, .site-loading-dots span { animation: none; }
}
.language-switch { display: flex; justify-content: flex-end; gap: 5px; margin-bottom: 16px; }
.language-switch button {
  min-width: 84px; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--glass-button); color: var(--ink);
  font: inherit; font-size: .95rem; cursor: pointer;
}
/* Show one action on every screen: switch to the other language. */
.language-switch button[aria-pressed="true"] { display: none; }
.language-switch button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.site-home-link {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line, #51657a);
  border-radius: 8px;
  background: var(--glass-button, #ffffff12);
  color: var(--ink, #edf9ff);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.site-home-link svg { width: 18px; height: 18px; flex: 0 0 auto; }
.site-home-link:hover { border-color: var(--accent, #73e4ff); }
.site-home-link:focus-visible { outline: 3px solid var(--accent, #73e4ff); outline-offset: 3px; }
.course-home .site-home-link { display: none; }
.course-home:has(#qualificationList .selected) .site-home-link { display: inline-flex; }
/* Compact controls on phones. */
@media (max-width: 820px), (max-width: 1024px) and (max-height: 500px) and (orientation: landscape) {
  .course-home:has(.picker[data-active-column="0"] #qualificationList) .site-home-link { display: none; }
  .language-switch button { min-width: 72px; padding: 8px 10px; font-size: .875rem; }
  .site-home-link { width: 44px; padding: 6px; }
  .site-home-link span { display: none; }
  .study-page .resource-topbar { padding-right: 88px; }
}
.course-home .china-intro { margin-top: 16px; color: var(--muted); line-height: 1.8; }
.course-home .topbar > h1 { font-size: clamp(1.85rem, 4vw, 3.4rem); line-height: 1.3; }
.locale-attribution { color: inherit; font-size: .75rem; }
body .legal-footer {
  position: relative;
  align-items: center;
  color: var(--muted, #b6c4d4);
}
.legal-footer > * { min-width: 0; max-width: 100%; }
.legal-footer-record { display: inline-flex; align-items: center; gap: .35rem; }
.legal-footer-record img { display: block; flex: 0 0 18px; width: 18px; height: 20px; object-fit: contain; }
.legal-footer-record span { min-width: 0; line-height: 1.5; overflow-wrap: anywhere; }
@media (max-width: 820px) {
  body .legal-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 8px;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }
}
html[lang="en"] .china-subject-english { font-size: inherit; color: inherit; }
.bilingual-course-label { display: block; min-width: 0; line-height: 1.5; overflow-wrap: anywhere; }
.bilingual-course-label .bilingual-course-label-chinese { display: block; }
.bilingual-course-label .bilingual-course-label-english {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: max(.875rem, .85em);
  font-weight: 500;
}
#unitList .bilingual-course-label { font-size: 1rem; }
.class-card .bilingual-course-label {
  display: block;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  color: var(--ink);
  font-size: 1rem;
  font-weight: inherit;
  line-height: 1.5;
}
.unit-class-grid .class-card strong.bilingual-lesson-title {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
  line-height: 1.5;
}
.class-card .bilingual-course-label > span {
  display: block;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}
.class-card .bilingual-course-label .bilingual-course-label-english {
  margin-top: 4px;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 500;
}
html[lang^="zh"] .toefl-framework .toefl-practice-button strong {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .2em .65em;
}
html[lang^="zh"] .toefl-framework .toefl-practice-button strong .toefl-cn-task-english {
  margin: 0;
  min-width: 0;
  color: var(--muted, #bac9da);
  font-size: .9em;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
}

/* Keep the homepage brand and language choices on one aligned row. */
.course-home .topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 16px;
}
.course-home .topbar > .brand-lockup {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  margin: 0;
}
.course-home .topbar > .language-switch {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
}
.course-home .topbar > h1 { grid-column: 1 / -1; }
@media (max-width: 420px) {
  .course-home .brand-lockup { gap: 6px; }
  .course-home .app-logo { width: 32px; height: 32px; }
  .course-home .eyebrow { font-size: .75rem; }
  .course-home .language-switch button { padding: 8px 10px; font-size: .875rem; }
}

/* Use open, readable strokes for Chinese course titles. */
html[lang^="zh"] .bilingual-course-label .bilingual-course-label-chinese {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
  font-weight: 500;
  font-size: 1.05em;
  font-synthesis: none;
  line-height: 1.6;
  letter-spacing: .015em;
  text-wrap: balance;
  text-shadow: none;
}

/* Keep registration records visible in China, independently of site address and UI language. */
html[data-visitor-region="international"] .legal-footer a[href^="https://beian.miit.gov.cn/"],
html[data-visitor-region="international"] .legal-footer a[href^="https://beian.mps.gov.cn/"] {
  display: none;
}
