/* Theme surfaces are separate from brand white/navy, which also colour text. */
:root {
  color-scheme: light;
  --surface: #ffffff;
  --surface-soft: #f5f6f8;
  --theme-ink: #172b43;
  --theme-muted: #62718b;
  --theme-line: #dce3ec;
  --theme-accent: #92651f;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #172538;
  --surface-soft: #101c2d;
  --theme-ink: #e3eaf4;
  --theme-muted: #aab9ce;
  --theme-line: #304158;
  --theme-accent: #edbe70;
  --text: #e3eaf4;
  --muted: #aab9ce;
  --offwhite: #101c2d;
  --light: #203149;
  --card: #172538;
  --border: #304158;
  --green: #52dba0;
  --red: #ff8585;
  --shadow: 0 8px 40px #00000030;
  --shadow2: 0 2px 14px #00000020;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--theme-line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--theme-ink);
  font: 600 .74rem var(--font-body);
  cursor: pointer;
  touch-action: manipulation;
}
.theme-toggle:hover { border-color: var(--theme-accent); }
.theme-toggle:focus-visible { outline: 3px solid var(--theme-accent); outline-offset: 3px; }
.theme-icon { width: 18px; height: 18px; background: currentColor; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2m0 16v2M2 12h2m16 0h2M5 5l1.5 1.5m11 11L19 19M5 19l1.5-1.5m11-11L19 5'/%3E%3C/svg%3E") center / contain no-repeat; }
[data-theme="dark"] .theme-icon { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='M20.5 14A8.8 8.8 0 0 1 10 3.5 9 9 0 1 0 20.5 14Z'/%3E%3C/svg%3E"); }
@media (prefers-reduced-motion: no-preference) {
  .theme-changing *, .theme-changing *::before, .theme-changing *::after {
    transition: background-color .24s ease, color .24s ease, border-color .24s ease, box-shadow .24s ease !important;
  }
}

/* The entry page follows the theme too, including its payment and plan cards. */
[data-theme="light"] #login { background: radial-gradient(ellipse at 5% 15%, #e7edf5, transparent 55%), #f5f6f8; }
[data-theme="light"] #login::before { background-image: radial-gradient(#172b4310 1px, transparent 1px); }
[data-theme="light"] #login :is(.access-info, .access-brand span, .access-slogan, .access-plan-price, .access-course-item strong, .payment-method strong) { color: var(--theme-ink); }
[data-theme="light"] #login :is(.access-desc, .access-path-label, .access-plan-name, .access-plan-price span, .access-plan-desc, .access-course-item span, .access-benefit, .access-benefit i, .access-payment-title, .payment-method span, .payment-holder, .payment-note, .access-language) { color: var(--theme-muted); }
[data-theme="light"] #login :is(.access-eyebrow, .access-slogan .gold, .access-brand b, .access-student-link, .access-benefits-title, .access-path-label > span:last-child) { color: var(--theme-accent); }
[data-theme="light"] #login :is(.access-plan, .access-payment, .access-language select, .access-path-steps span) { background: var(--surface); border-color: var(--theme-line); color: var(--theme-ink); }
[data-theme="light"] #login .access-plan.featured { background: #fff7e8; border-color: #c8a361; }
[data-theme="light"] #login :is(.access-topbar, .access-course-item, .payment-method, .payment-note) { border-color: var(--theme-line); }
[data-theme="light"] #login .access-path-steps::before { background: var(--theme-line); }
[data-theme="light"] #login .access-path-steps span:first-child { background: #f0bb5b; border-color: #f0bb5b; }
[data-theme="light"] #login .access-path-steps span:last-child { color: var(--theme-accent); border-color: #c8a361; }
[data-theme="dark"] .access-card { background: var(--surface); border-color: var(--theme-line); }
[data-theme="dark"] :is(.access-card-title, .access-code-label) { color: var(--theme-ink); }
[data-theme="dark"] :is(.access-card-eyebrow, #login-prompt, .access-card-note, #toggle-access-code) { color: var(--theme-muted); }
[data-theme="dark"] .access-card-note { border-color: var(--theme-line); }
[data-theme="dark"] .access-card-note a:hover { color: var(--gold2); }
[data-theme="dark"] .access-card-symbol { background: #352f24; color: var(--gold2); }
[data-theme="dark"] #password { background: var(--surface-soft); color: var(--theme-ink); border-color: var(--theme-line); }

/* Student workspace, including content created after opening an activity. */
[data-theme="dark"] body { background: #0d1726; }
[data-theme="dark"] #main-content {
  --studio-ink: var(--theme-ink);
  --studio-soft: #0d1726;
  --studio-line: var(--theme-line);
  --studio-accent: var(--theme-accent);
}
[data-theme="dark"] .studio-ready #navbar { background: #172538f5; border-color: var(--theme-line); }
[data-theme="dark"] .studio-ready #navbar :is(.lang-switcher, .hamburger) { background: var(--surface-soft); border-color: var(--theme-line); }
[data-theme="dark"] .studio-ready #navbar .lang-btn { color: var(--theme-muted); }
[data-theme="dark"] .studio-ready #navbar .lang-btn:is(.active, :hover) { background: #304158; color: var(--gold2); }
[data-theme="dark"] .studio-ready #navbar .hamburger span { background: var(--theme-ink); }
[data-theme="dark"] :is(.studio-top-label strong, .studio-ready #navbar .nav-logo) { color: var(--theme-ink); }
[data-theme="dark"] #main-content :is(.study-action, .continue-panel, .level-card, .listening-card, .library-toolbar, .library-sort, .lib-book, .grammar-search, .grammar-card, .vocab-workspace, .dictionary-search-row, .ll-dict-result, .recent-panel, .brit-col, .slang-card, .daily-card, .placement-container, .pt-question, .tutor-box, .contact-form, .contact-item, .modal-box, .modal-body, .modal-tabs, .quiz-opt, .lib-tab, .continue-chip, .studio-filter, .btn-fc) {
  background: var(--surface); color: var(--theme-ink); border-color: var(--theme-line);
}
[data-theme="dark"] #main-content :is(.continue-panel-chip, .level-topic, .btn-level, .lib-chip, .studio-track-play, .daily-challenge-text, .pt-opt, .modal-tab, .example-box, .vocab-item, .quiz-section, .recent-item, .resource-list li, .ll-dict-card, .ll-dict-example, .ll-dict-tag) {
  background: var(--surface-soft); color: var(--theme-ink); border-color: var(--theme-line);
}
[data-theme="dark"] #main-content :is(.section-title, .study-heading h2, .level-title, .listening-card h3, .studio-book-title, .grammar-card h3, .vocab-guide h3, .recent-heading, .ll-dict-empty-title, .ll-dict-word, .ll-dict-ipa, .ll-dict-section h4, .brit-col h3, .slang-word, .daily-card h3, .pt-q-text, .tutor-name, .contact-label, .form-group label, .lesson-block h3, .example-box strong, .vocab-word, .quiz-q p, .library-continue-title, .continue-panel-title, .resource-list strong, .comp-table td:first-child, .btn-text) { color: var(--theme-ink); }
[data-theme="dark"] #main-content :is(.section-sub, .study-action > span:not(.study-icon), .study-placement, .continue-panel-heading > span, .continue-panel-chip div span, .level-cefr, .level-desc, .listening-card > p, .lib-desc, .vocab-guide p, .vocab-guide li, .slang-meaning, .daily-card p, .resource-list a) { color: var(--theme-muted); }
[data-theme="dark"] #main-content :is(#slang, #daily) .section-sub { color: var(--theme-muted); }
[data-theme="dark"] #main-content :is(.section-tag, .study-eyebrow, .studio-inline-link) { color: var(--theme-accent); }
[data-theme="dark"] #main-content :is(#slang, #daily) .section-tag { color: var(--theme-accent); }
[data-theme="dark"] #main-content .slang-ex { color: #d8ba87 !important; }
[data-theme="dark"] #main-content :is(input, select, textarea) { background: var(--surface-soft); color: var(--theme-ink); border-color: var(--theme-line); }
[data-theme="dark"] ::placeholder { color: #9baac0; opacity: 1; }
[data-theme="dark"] #main-content :is(.table-responsive, .resource-list li, .resource-list a) { border-color: var(--theme-line); }
[data-theme="dark"] #main-content table th { background: #23354c; color: var(--theme-ink); }
[data-theme="dark"] #main-content table td { border-color: var(--theme-line); }
[data-theme="dark"] #main-content .comp-table td:nth-child(2) { color: #83b6ff; }
[data-theme="dark"] #main-content .comp-table td:nth-child(3) { color: var(--red); }
[data-theme="dark"] #main-content .lib-cover { background: linear-gradient(145deg, #25364c, #1d2a3e); }
[data-theme="dark"] #main-content :is(.btn-level:hover, .btn-fc:hover, .modal-tab.active, .lib-tab.active, .studio-filter[aria-pressed="true"], .pt-opt.selected) { background: #304158; border-color: var(--theme-accent); color: var(--gold2); }
[data-theme="dark"] #main-content :is(.btn-fc.primary, .btn-fc.primary:hover) { background: #f2c57a; border-color: #f2c57a; color: #172b43; }
[data-theme="dark"] #main-content :is(.btn-daily, .lib-download, .continue-panel-icon, .studio-tool-icon, .vocab-guide li::before) { background: #352f24; color: #edbe70; border-color: #665236; }
[data-theme="dark"] #main-content .ll-dict-status.success { color: var(--green); }
[data-theme="dark"] #main-content :is(.contact-form > h3, .quiz-section > h3) { color: var(--theme-ink) !important; }
[data-theme="dark"] #main-content :is(.ll-dict-block h4, .ll-dict-list-item strong, .ll-dict-box strong, .ll-dict-chip) { color: var(--theme-ink); }
[data-theme="dark"] #main-content .ll-audio-btn { background: var(--surface); color: var(--theme-ink); }
[data-theme="dark"] #main-content .ll-audio-btn:hover { background: #304158; }
[data-theme="dark"] #main-content .ll-audio-btn.playing { background: var(--gold); color: var(--navy); }

@media (max-width: 760px) {
  #navbar .theme-toggle { padding: 8px; }
  #navbar [data-theme-label] { display: none; }
}
@media (max-width: 450px) {
  .access-topbar { flex-wrap: wrap; }
  .access-topbar-actions { margin-left: auto; gap: 8px; }
  .access-topbar [data-theme-label] { display: none; }
  .access-topbar .theme-toggle { padding: 8px; }
  .studio-ready #navbar .nav-logo { display: none; }
}
