:root{--private-bg:var(--page-bg,#fff8f2);--private-paper:var(--surface-solid,#fff);--private-surface:var(--surface,#fff);--private-soft:var(--surface-muted,#f1f5f9);--private-ink:var(--text,#172033);--private-muted:var(--muted,#536174);--private-line:var(--stroke,#d9e1eb);--private-shadow:var(--shadow,0 18px 55px rgba(0,0,0,.12));--accent-primary:var(--primary2,#7c3aed);--accent-primary-deep:var(--primary,#2563eb);--accent-nature:var(--good,#16a34a);--accent-gold:var(--amber,#b45309);--wine:var(--primary,#2563eb);--rose:var(--primary2,#7c3aed);--cream:var(--page-bg,#fff8f2);--paper:var(--surface-solid,#fff);--surface-soft:var(--private-soft);--ink:var(--private-ink);--line:var(--private-line);--game-card:var(--private-paper);--game-soft:var(--private-soft);--game-line:var(--private-line);--text-primary:var(--private-ink);--text-secondary:var(--private-muted);--lads-bg:var(--private-bg);--lads-surface:var(--private-surface);--lads-text:var(--private-ink);--lads-muted:var(--private-muted);--lads-primary:var(--primary,#2563eb);--lads-border:var(--private-line)}
:root[data-theme-group="dark"]{color-scheme:dark}
body.lads-portal{background:var(--page-bg,var(--lads-bg));color:var(--text,var(--lads-text))}
.lads-topbar,.hero-card,.lesson-card,.curriculum-card,.daily-phrase-card,.glossary-card,.game-card{background:var(--surface,var(--lads-surface));color:var(--text,var(--lads-text));border-color:var(--stroke,var(--lads-border))}
.esl-profile-button{border:1px solid var(--border,var(--lads-border));border-radius:999px;padding:.55rem .85rem;background:var(--surface,var(--lads-surface));color:var(--text-primary,var(--lads-text));font:inherit;font-weight:800;cursor:pointer}
.esl-profile-dialog{width:min(92vw,480px);padding:0;border:0;border-radius:24px;background:transparent;color:var(--text-primary,#172033)}.esl-profile-dialog::backdrop{background:rgba(10,18,32,.65);backdrop-filter:blur(4px)}
.esl-profile-card{position:relative;padding:26px;background:var(--surface,#fff);border:1px solid var(--border,#d9e1eb);border-radius:24px;box-shadow:0 24px 70px rgba(0,0,0,.25)}.esl-profile-card h2{margin:.3rem 0}.esl-profile-note{color:var(--text-secondary,#536174);line-height:1.55}.esl-profile-close{position:absolute;right:14px;top:12px;border:0;background:transparent;color:inherit;font-size:1.8rem;cursor:pointer}
.esl-profile-tabs{display:flex;gap:8px;margin:16px 0}.esl-profile-tabs button,.esl-profile-card form button,.esl-profile-signed button{border:1px solid var(--border,#d9e1eb);border-radius:12px;padding:.7rem .9rem;background:var(--surface-alt,#eef3f9);color:inherit;font-weight:800;cursor:pointer}.esl-profile-tabs button.active,.esl-profile-card form>button{background:var(--primary,#2563eb);color:var(--on-primary,#fff)}
.esl-profile-card form{display:grid;gap:12px}.esl-profile-card form[hidden]{display:none}.esl-profile-card label{display:grid;gap:5px;font-weight:700}.esl-profile-card input{width:100%;box-sizing:border-box;padding:.75rem;border:1px solid var(--border,#cbd5e1);border-radius:11px;background:var(--input-bg,var(--surface,#fff));color:inherit;font:inherit}.esl-profile-message{min-height:1.5em;color:var(--primary,#2563eb);font-weight:700}.esl-profile-signed{display:grid;gap:7px;padding:14px;border-radius:14px;background:var(--surface-alt,#eef3f9)}
@media(max-width:680px){.esl-profile-button{padding:.45rem .65rem;font-size:.84rem}.esl-profile-card{padding:22px 18px}}

/* V279.6 — bridge every ESL Public screen to the shared twelve-theme palette. */
:root[data-theme][data-theme-resolved]{
  --private-bg:var(--page-bg);
  --private-paper:var(--surface-solid);
  --private-surface:var(--surface);
  --private-soft:var(--surface-muted);
  --private-ink:var(--theme-readable-text,var(--text));
  --private-muted:var(--theme-readable-muted,var(--muted));
  --private-line:var(--stroke);
  --private-shadow:var(--shadow);
  --wine:var(--primary);
  --rose:var(--primary2);
  --rose-soft:var(--primary-soft);
  --cream:var(--page-bg);
  --paper:var(--surface-solid);
  --ink:var(--theme-readable-text,var(--text));
  --line:var(--stroke);
  --text-primary:var(--theme-readable-text,var(--text));
  --text-secondary:var(--theme-readable-muted,var(--muted));
  --text-support:var(--theme-readable-muted,var(--muted));
  --text-pronunciation:var(--theme-link-text,var(--primary));
  --panel-solid:var(--surface-solid);
  --panel-soft:var(--surface-muted);
  --panel-raised:var(--surface-solid);
  --focus-ring:var(--theme-link-text,var(--primary));
  --button-primary-start:var(--theme-button-start,var(--primary));
  --button-primary-end:var(--theme-button-end,var(--primary2));
  --button-primary-text:var(--theme-button-text,#fff);
  --game-green:var(--primary);
  --game-green-dark:var(--theme-link-text,var(--primary));
  --game-lime:var(--primary2);
  --game-sky:var(--primary2);
  --game-gold:var(--amber);
  --game-red:var(--bad);
  --game-purple:var(--primary2);
  --game-card:var(--surface-solid);
  --game-soft:var(--surface-muted);
  --game-line:var(--stroke);
  --game-shadow:var(--shadow);
  --learning-note-bg-start:color-mix(in srgb,var(--primary) 18%,var(--surface-solid));
  --learning-note-bg-end:color-mix(in srgb,var(--primary2) 16%,var(--surface-solid));
  --learning-note-text:var(--theme-readable-text,var(--text));
  --learning-note-support:var(--theme-readable-muted,var(--muted));
  --learning-note-accent:var(--theme-link-text,var(--primary));
}

:root[data-theme] body.lads-portal{
  color:var(--theme-readable-text,var(--text))!important;
  background:var(--theme-gradient,linear-gradient(180deg,var(--page-bg),var(--surface-solid)))!important;
}

:root[data-theme] body.lads-portal :where(
  .lads-topbar,.game-topbar,.course-hero,.lesson-hero,.personal-greeting,
  .journey-card,.content-card,.aside-card,.source-merge article,.word-card,
  .sentence-card,.dialogue-card,.gate-card,.daily-phrase-card,.lesson-stage,
  .lesson-stage-summary,.lesson-stage-body,.private-learning-step-strip,
  .practice-conversation,.conversation-more-options,.conversation-toolbar button,
  .glossary-shell,.glossary-card,.glossary-word-row,.esl-profile-card,
  .esl-profile-signed,.game-card,.practice-card,.path-section,.unit-copy,
  .challenge-card,.answer-option,.match-option,.result-card,.help-dialog,
  .stat-dialog-shell,.game-mobile-stats-panel,.game-mobile-stat,
  .private-tools-popover,.mobile-action-bar
){
  color:var(--theme-readable-text,var(--text))!important;
  background-color:var(--surface-solid)!important;
  border-color:var(--stroke)!important;
}

:root[data-theme] body.lads-portal :where(
  .lesson-hero,.course-hero,.game-hero
){
  color:var(--theme-readable-text,var(--text))!important;
  background:linear-gradient(135deg,var(--surface-solid),var(--primary-soft))!important;
  border-color:var(--stroke)!important;
}

:root[data-theme] body.lads-portal :where(
  h1,h2,h3,h4,.lesson-stage-summary-copy strong,.game-hero h1,
  .path-heading h2,.challenge-prompt,.result-card h1,.unit-copy strong,
  .practice-card strong,.answer-option,.match-option,.private-brand,.game-brand,.game-back
){color:var(--theme-readable-text,var(--text))!important}

:root[data-theme] body.lads-portal :where(
  p,small,.instruction-english,.thai-copy,.scenario-primary,.scenario-english,
  .lesson-stage-summary-copy small,.objective-list small,.path-heading>p,
  .challenge-helper,.unit-copy span,.practice-card small,.result-card>p,
  .help-dialog li p,.game-mobile-stats-header small,.glossary-pronunciation,
  .glossary-meaning,.esl-profile-note
){color:var(--theme-readable-muted,var(--muted))}

:root[data-theme] body.lads-portal :where(
  .eyebrow,.game-kicker,.challenge-type,.unit-copy small,.pronunciation,
  .lesson-hero h2,.course-hero h1 span,.rice-progress-copy strong
){color:var(--theme-link-text,var(--primary))!important}

:root[data-theme] body.lads-portal .mobile-action-bar :where(a,button){
  color:var(--theme-link-text,var(--primary))!important;
}
:root[data-theme] body.lads-portal .private-tools-popover :where(a,summary){
  color:var(--theme-readable-text,var(--text))!important;
}

:root[data-theme] body.lads-portal :where(
  .quiz-question label,.builder-answer,.word-bank button,.teacher-structure,
  .daily-phrase-main,.daily-phrase-insights section,.vocabulary-voice-control,
  .result-stats article,.help-dialog li,.round-progress,.mobile-stat-tabs,
  .mobile-stat-tabs .stat-tab,.game-settings,.spell-input
){
  color:var(--theme-readable-text,var(--text))!important;
  background:var(--surface-muted)!important;
  border-color:var(--stroke)!important;
}

:root[data-theme] body.lads-portal :where(
  .primary-button,.complete-button,.quest-button.primary,.mobile-action-bar .primary
){
  color:var(--theme-button-text,#fff)!important;
  background:linear-gradient(135deg,var(--theme-button-start,var(--primary)),var(--theme-button-end,var(--primary2)))!important;
  border-color:transparent!important;
}

:root[data-theme] body.lads-portal :where(
  .soft-button,.quiet-button,.quest-button,.text-button,.speak-button,
  .game-audio-button,.mini-audio,.icon-button,.round-close,.dialog-close,
  .esl-profile-button,.esl-profile-tabs button,.esl-profile-card form button,
  .esl-profile-signed button
){
  color:var(--theme-link-text,var(--primary))!important;
  background:var(--surface-solid)!important;
  border-color:var(--stroke)!important;
}

:root[data-theme] body.lads-portal .answer-option.is-selected,
:root[data-theme] body.lads-portal .match-option.is-selected{
  color:var(--theme-readable-text,var(--text))!important;
  background:var(--primary-soft)!important;
  border-color:var(--primary)!important;
}
:root[data-theme] body.lads-portal .match-option.is-matched,
:root[data-theme] body.lads-portal .answer-panel{
  color:var(--theme-good-text,var(--good))!important;
  background:var(--good-soft)!important;
  border-color:var(--good)!important;
}
:root[data-theme] body.lads-portal .match-option.is-wrong,
:root[data-theme] body.lads-portal .answer-panel.is-wrong{
  color:var(--theme-bad-text,var(--bad))!important;
  background:var(--bad-soft)!important;
  border-color:var(--bad)!important;
}
:root[data-theme] body.lads-portal .answer-panel .answer-copy :where(strong,p){color:inherit!important}

:root[data-theme] body.game-portal .game-hero-copy>p:not(.game-kicker){
  color:var(--theme-readable-muted,var(--muted))!important;
}
:root[data-theme] body.game-portal .game-hero h1 span{color:var(--theme-link-text,var(--primary))!important}
:root[data-theme] body.game-portal .unit-node{
  color:var(--theme-readable-muted,var(--muted));
  background:var(--surface-muted);
  box-shadow:0 7px 0 color-mix(in srgb,var(--stroke) 78%,var(--surface-solid)),var(--shadow2);
}
:root[data-theme] body.game-portal .path-unit.is-unlocked .unit-node{
  color:var(--theme-button-text,#fff);
  background:linear-gradient(145deg,var(--primary2),var(--primary));
  box-shadow:0 7px 0 color-mix(in srgb,var(--primary) 72%,black),var(--shadow2);
}
:root[data-theme] body.game-portal .path-unit.is-complete .unit-node{
  color:#1f2937;
  background:linear-gradient(145deg,color-mix(in srgb,var(--amber) 55%,white),var(--amber));
}
:root[data-theme] body.game-portal .path-unit.is-current .unit-node:after{
  color:var(--theme-link-text,var(--primary));
  background:var(--surface-solid);
  border:1px solid var(--stroke);
}
:root[data-theme-group="dark"] body.game-portal :where(.hero-world-art,.unit-art,.challenge-topic-art){
  background:var(--surface-muted)!important;
  border-color:var(--stroke)!important;
}
:root[data-theme-group="dark"] body.game-portal .hero-world-art{filter:saturate(.75) brightness(.72)}

/* Keep the selector reachable above ESL Public's mobile action bar. */
@media(max-width:700px){
  body.lads-portal .theme-switcher{right:12px;bottom:calc(88px + env(safe-area-inset-bottom,0px))}
  body.lads-portal .theme-menu{max-height:calc(100dvh - 176px)}
}
