/*
 * PINTARA v4.6.1 — Unified Theme Engine
 * Canonical palette: ThemeManagerService -> body --ptm-* variables.
 * Each module retains its layout/game rules; only non-semantic UI surfaces,
 * text, borders and actions are connected to the admin-defined palette.
 * No global .active, canvas, SVG/artwork, game tile, reward or quiz feedback overrides.
 */
body.ptm-parent,body.ptm-paud,body.ptm-student{
  --put-page:var(--ptm-bg);
  --put-card:var(--ptm-surface);
  --put-nav:var(--ptm-sidebar);
  --put-accent:var(--ptm-accent);
  --put-ink:var(--ptm-text);
  --put-on-accent:var(--ptm-accent-ink);
  --put-on-sidebar:var(--ptm-sidebar-ink);
  --put-border:var(--ptm-border,rgba(244,244,244,.20));
  --put-muted:var(--ptm-muted,var(--ptm-text));
  --put-input:var(--ptm-input,var(--ptm-bg));
  --put-head-gradient:linear-gradient(122deg,var(--ptm-surface),var(--ptm-bg));
  accent-color:var(--put-accent);
}
/* Global layout and explicitly neutral components. */
body:is(.ptm-parent,.ptm-paud,.ptm-student){background:var(--put-page)!important;color:var(--put-ink)!important;}
body:is(.ptm-parent,.ptm-paud,.ptm-student) :is(.page-wrap,.app-main){background:var(--put-page)!important;color:var(--put-ink);}
body:is(.ptm-parent,.ptm-paud,.ptm-student) :is(.sidebar){background:var(--put-nav)!important;border-color:var(--put-border)!important;}
body:is(.ptm-parent,.ptm-paud,.ptm-student) .sidebar :is(nav a,.nav-label){color:var(--put-on-sidebar)!important;}
body:is(.ptm-parent,.ptm-paud,.ptm-student) .sidebar nav a:is(.active,[aria-current=page],:hover){background:var(--put-accent)!important;color:var(--put-on-accent)!important;}
body:is(.ptm-parent,.ptm-paud,.ptm-student) :is(.topbar,.mobile-nav){background:var(--put-nav)!important;color:var(--put-on-sidebar)!important;border-color:var(--put-border)!important;}
body:is(.ptm-parent,.ptm-paud,.ptm-student) .topbar :is(strong,small){color:var(--put-on-sidebar)!important;}
body:is(.ptm-parent,.ptm-paud,.ptm-student) :is(.card,.panel,.stat,.empty-state){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body:is(.ptm-parent,.ptm-paud,.ptm-student) :is(.card,.panel,.stat,.empty-state) :is(h1,h2,h3,strong,p,small){color:inherit;}
/* Parent: family, monitoring, profile and Premium. Match only neutral surfaces. */
body.ptm-parent :is(.pex-card,.pm384-module,.parent-profile-card,.parent-profile-section,.parent-family-card,.parent-summary-card,.parent-subscription-card,.parent-insight-card,.paud-parent-card){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-parent :is(.pex-card,.pm384-module,.parent-profile-card,.parent-family-card) :is(h2,h3,p,small,strong){color:var(--put-ink)!important;}
body.ptm-parent :is(.pm384-parent-nav,.pex-parent-nav){background:var(--put-nav)!important;color:var(--put-on-sidebar)!important;}
body.ptm-parent :is(.btn.primary,.pex-button,.parent-profile-save){background:var(--put-accent)!important;color:var(--put-on-accent)!important;border-color:var(--put-accent)!important;}
/* PAUD: leave paintings, progress/success indicators, counting objects and toys alone. */
body.ptm-paud.pintara-paud-mode :is(.paud-joy,.joy-home,.joy-play){color:var(--put-ink)!important;}
body.ptm-paud.pintara-paud-mode :is(.joy-hero,.joy-play-hero){background:var(--put-head-gradient)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-paud.pintara-paud-mode :is(.joy-hero,.joy-play-hero) :is(h1,h2,p,.joy-subtitle){color:var(--put-ink)!important;}
body.ptm-paud.pintara-paud-mode :is(.joy-paper,.joy-adult-tip,.joy-adult-details,.joy-library,.joy-category,.joy-group){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-paud.pintara-paud-mode :is(.joy-paper,.joy-adult-tip,.joy-adult-details,.joy-library,.joy-category,.joy-group) :is(h2,h3,p,small,strong){color:var(--put-ink)!important;}
body.ptm-paud.pintara-paud-mode :is(.joy-primary-action,.joy-back,.joy-speak){background:var(--put-accent)!important;color:var(--put-on-accent)!important;border-color:var(--put-accent)!important;}
/* SD–SMA app foundation: override v4.5.9 palette aliases without touching game drawings. */
body.ptm-student:not(.pds-age-paud){
  --sp-navy:var(--ptm-bg);--sp-blue:var(--ptm-surface);--sp-teal:var(--ptm-accent);
  --sp-white:var(--ptm-text);--sp-dim:var(--put-muted);--sp-line:var(--put-border);
  --bg:var(--ptm-bg);--card:var(--ptm-surface);--surface:var(--ptm-surface);
  --surface-2:var(--ptm-accent);--ink:var(--ptm-text);--text:var(--ptm-text);
  --muted:var(--put-muted);--line:var(--put-border);--p459-accent:var(--ptm-accent);
  --ql-card:var(--ptm-surface);
}
/* World overview */
body.ptm-student:not(.pds-age-paud) :is(.world-hero,.world-section-header){background:var(--put-head-gradient)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.world-dashboard-actions a,.world-stats-strip>div,.world-portal,.pds459-student-guide){background:var(--put-card)!important;color:var(--put-ink)!important;border:1px solid var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.world-dashboard-actions a,.world-stats-strip>div,.world-portal,.pds459-student-guide) :is(b,strong,p,small,h2,h3){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) :is(.world-wallet span,.world-portal .portal-enter){background:var(--put-accent)!important;color:var(--put-on-accent)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) .pds459-student-guide a{background:var(--put-accent)!important;color:var(--put-on-accent)!important;}
/* Writing Studio: canvas/guide paper deliberately remain light for handwriting clarity. */
body.ptm-student:not(.pds-age-paud) .writing-app{color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) .writing-hero{background:var(--put-head-gradient)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) .writing-hero :is(h1,p,.writing-kicker){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) :is(.writing-panel,.writing-workspace,.writing-history,.writing-growth>div,.writing-history-item){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.writing-panel,.writing-workspace,.writing-history,.writing-growth>div,.writing-history-item) :is(h2,p,small,strong,label,.writing-note){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) :is(.writing-modes button,.writing-status,.writing-tips,.writing-extra input,.writing-extra select){background:var(--put-input)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) .writing-modes button small{color:var(--put-muted)!important;}
body.ptm-student:not(.pds-age-paud) :is(.writing-modes button.active,.writing-actions button.primary){background:var(--put-accent)!important;color:var(--put-on-accent)!important;border-color:var(--put-accent)!important;}
body.ptm-student:not(.pds-age-paud) .writing-modes button.active :is(strong,small,i){color:var(--put-on-accent)!important;}
/* SpeakUp: recording indicator and evaluation rubric semantics remain independently colored. */
body.ptm-student:not(.pds-age-paud) .sp390{--sp-panel:var(--put-card);--sp-line:var(--put-border);--sp-muted:var(--put-muted);color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) .sp390 .sp390-hero{background:var(--put-head-gradient)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.sp390-card,.sp390-mission,.sp390-preview,.sp390-history-item,.sp390-stats article,.sp390-mode label,.sp394-feedback,.sp394-aspect,.sp390-check){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.sp390-card,.sp390-mission,.sp390-preview,.sp390-history-item,.sp390-stats article,.sp390-mode label,.sp394-feedback,.sp394-aspect,.sp390-check) :is(h1,h2,h3,p,small,span,strong,label){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) :is(.sp390 .sp390-counter,.sp390 .sp390-hero-pills span,.sp390 .sp390-guide,.sp390 .sp390-help){background:var(--put-input)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) .sp390 :is(.sp390-guide p,.sp390-guide strong,.sp390-kicker,.sp390-muted){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) :is(.sp390-primary,.sp390-outline,.sp394-feedback>summary){background:var(--put-accent)!important;color:var(--put-on-accent)!important;border-color:var(--put-accent)!important;}
body.ptm-student:not(.pds-age-paud) :is(.sp390 input:not([type=checkbox]):not([type=radio]),.sp390 textarea,.sp390 select){background:var(--put-input)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
/* Math Studio: keep handwritten board and graph mathematical colors intact. */
body.ptm-student:not(.pds-age-paud) :is(.math-hero,.math-studio .math-hero){background:var(--put-head-gradient)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) .math-hero :is(h1,p,strong){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) :is(.math-modes,.math-work,.math-history,.math-stats>div,.math-history-grid>div){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.math-modes,.math-work,.math-history,.math-stats>div) :is(h2,h3,p,small,span,strong){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) .math-modes button{background:var(--put-input)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.math-modes button.active,.math-actions .primary){background:var(--put-accent)!important;color:var(--put-on-accent)!important;border-color:var(--put-accent)!important;}
body.ptm-student:not(.pds-age-paud) .math-modes button.active :is(strong,small){color:var(--put-on-accent)!important;}
/* Learning Map: road/path, route line and completed/unlocked state markers stay distinct. */
body.ptm-student:not(.pds-age-paud) :is(.adventure-map-card,.learning-map-head,.adventure-map-heading,.path-lesson-row,.lesson-card,.subject-card){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.adventure-map-card,.learning-map-head,.adventure-map-heading,.path-lesson-row,.lesson-card,.subject-card) :is(h1,h2,h3,p,small,strong,.adventure-map-card-description,.adventure-map-card-kicker){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) :is(.adventure-map-open,.learning-map-head .btn.primary){background:var(--put-accent)!important;color:var(--put-on-accent)!important;border-color:var(--put-accent)!important;}
/* Quest portal cards. Preserve illustrations and score/answer semantic colors. */
body.ptm-student:not(.pds-age-paud) :is(.quest-lobby-hero,.quest-lobby-heading){background:var(--put-head-gradient)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.quest-lobby-hero,.quest-lobby-heading) :is(h1,h2,p){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) :is(.quest-portal-card,.quest-lobby-empty,.quest-lobby-footnote){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.quest-portal-card,.quest-lobby-empty,.quest-lobby-footnote) :is(h2,h3,p,small,.quest-portal-description,.quest-type-label){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) .quest-enter-button:not(:disabled){background:var(--put-accent)!important;color:var(--put-on-accent)!important;border-color:var(--put-accent)!important;}
/* Kingdom Quest: NEVER restyle canvas, building art, defense feedback or state colors. */
body.ptm-student:not(.pds-age-paud) .kq{--kq-bg:var(--put-page);--kq-ink:var(--put-ink);color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) .kq :is(.kq-hero,.kq-adventure-brief){background:var(--put-head-gradient)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) .kq :is(.kq-hero,.kq-adventure-brief) :is(h1,h2,p,small,strong){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) .kq :is(.kq-status>div,.kq-board-pane,.kq-sidebar,.kq-tab-panel,.kq-adventure-details,.kq-story-section,.kq-activity){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) .kq :is(.kq-status>div,.kq-board-pane,.kq-sidebar,.kq-tab-panel,.kq-adventure-details,.kq-story-section,.kq-activity) :is(h2,h3,h4,p,small,span,strong){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) .kq :is(.kq-tabs,.kq-board-heading,.kq-region-note){background:var(--put-input)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) .kq :is(.kq-tabs button:not(.active),.kq-button:not(.kq-primary),.kq-region-choice:not(.active)){background:var(--put-input)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) .kq :is(.kq-tabs button.active,.kq-button.kq-primary){background:var(--put-accent)!important;color:var(--put-on-accent)!important;border-color:var(--put-accent)!important;}
body.ptm-student:not(.pds-age-paud) .kq :is(.kq-tabs button.active,.kq-button.kq-primary) :is(i,span){color:var(--put-on-accent)!important;}
/* Additional content modules share generic neutral cards while keeping colored game effects. */
body.ptm-student:not(.pds-age-paud) :is(.geo360 .geo-panel,.geo360 .geo-history,.fraction-lab .fraction-panel,.reading-studio .reading-panel,.ai-tutor-panel,.schedule-card,.week-day){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.geo360 .geo-hero,.reading-studio .reading-hero){background:var(--put-head-gradient)!important;color:var(--put-ink)!important;}
/* Additional learning studios: neutral application chrome is theme-driven. */
body.ptm-student:not(.pds-age-paud) :is(.reading-hero,.pfrac-hero,.geo360 .geo-hero,.gw-lab .gw-hero,.ms332 .ms332-hero,.ai-hero){background:var(--put-head-gradient)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.reading-hero,.pfrac-hero,.geo360 .geo-hero,.gw-lab .gw-hero,.ms332 .ms332-hero,.ai-hero) :is(h1,h2,h3,p,small){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) :is(.reading-sidebar,.reading-history,.reading-record-card,.pfrac-card,.pfrac-config,.pfrac-history,.geo360 .geo-panel,.geo360 .geo-history,.gw-lab .gw-panel,.gw-lab .gw-history,.ms332 .ms332-card,.ms332 .ms332-history,.pintara-modes-card,.pintara-history-card){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.reading-sidebar,.reading-history,.reading-record-card,.pfrac-card,.pfrac-config,.pfrac-history,.geo360 .geo-panel,.geo360 .geo-history,.gw-lab .gw-panel,.gw-lab .gw-history,.ms332 .ms332-card,.ms332 .ms332-history,.pintara-modes-card,.pintara-history-card) :is(h2,h3,h4,p,strong,small){color:var(--put-ink)!important;}
body.ptm-student:not(.pds-age-paud) :is(.pfrac .pfrac-primary,.ms332 .ms332-primary,.reading-buttons .primary,.gw-lab .primary){background:var(--put-accent)!important;color:var(--put-on-accent)!important;border-color:var(--put-accent)!important;}
/* Secondary game interfaces: style outer chrome, not live stages, playing fields, or status cues. */
body.ptm-student:not(.pds-age-paud) :is(.sq400 .sq400-top,.soccer-hero,.sg410 .sg410-hero){background:var(--put-head-gradient)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-student:not(.pds-age-paud) :is(.sq400 .sq400-info,.sq400 .sq400-sidebar,.soccer-guide,.soccer-help,.sg410 .sg410-stats,.sg410 .sg410-history,.tabletop-coach-panel){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
/* PAUD/TK mini-games: retain physical object colors, game icons, feedback and art. */
body.ptm-paud.pintara-paud-mode :is(.paud-hero,.pg-hero){background:var(--put-head-gradient)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-paud.pintara-paud-mode :is(.paud-panel,.paud-parent,.pg-card,.pg-zone,.pg-section){background:var(--put-card)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body.ptm-paud.pintara-paud-mode :is(.paud-panel,.paud-parent,.pg-card,.pg-zone,.pg-section) :is(h2,h3,strong,p,small){color:var(--put-ink)!important;}
/* User-facing page headings should follow the selected palette even when a module hardcodes #fff. */
body:is(.ptm-parent,.ptm-paud,.ptm-student) .page-wrap> :is(.section-head,.page-heading,.page-header) :is(h1,h2,p){color:var(--put-ink)!important;}
/* Controls on neutral surfaces. Exclude canvas and range/radio/checkbox UI. */
body:is(.ptm-parent,.ptm-paud,.ptm-student) .page-wrap :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]),select,textarea):not(.writing-board *){background:var(--put-input)!important;color:var(--put-ink)!important;border-color:var(--put-border)!important;}
body:is(.ptm-parent,.ptm-paud,.ptm-student) .page-wrap :is(input,textarea)::placeholder{color:var(--put-muted)!important;opacity:.85;}
body:is(.ptm-parent,.ptm-paud,.ptm-student) :is(a,button,input,select,textarea,summary):focus-visible{outline:3px solid var(--ptm-focus,var(--put-ink))!important;outline-offset:3px;}
/* Preserve light writing surfaces and legible dark guides independently of theme. */
body.ptm-student:not(.pds-age-paud) .writing-board{background:#FBFBF7!important;color:#233348!important;}
/* Focus mode overlays, animation effects and game canvases are intentionally untouched. */
@media(prefers-reduced-motion:reduce){body:is(.ptm-parent,.ptm-paud,.ptm-student) :is(.world-portal,.writing-modes button,.quest-portal-card){transition:none!important;}}
@media print{body:is(.ptm-parent,.ptm-paud,.ptm-student) .page-wrap{background:#fff!important;color:#111!important}}
