/* Canonical subject tokens. Diagram colors remain meaningful and independent. */
#study,#qg.matematica-theme,body.study-active { --subject-bg:#20211B; --subject-surface:#2B2B20; --subject-raised:#3B3826; --subject-accent:#FFD700; --subject-secondary:#D4A43E; --subject-text:#FFF8E7; --subject-muted:#DED7BE; --subject-border:#B9AB78; --subject-focus:#FFE0A0; --subject-ok:#A9E2BE; --subject-error:#FFC0B8; }
#physics-study,#qg.fisica-theme,body.physics-reading { --subject-bg:#071D30; --subject-surface:#0C2A43; --subject-raised:#153C59; --subject-accent:#54D7E5; --subject-secondary:#8065D6; --subject-text:#EEF9FB; --subject-muted:#C3DAE9; --subject-border:#5F92AD; --subject-focus:#AEF8FF; --subject-ok:#A9E2BE; --subject-error:#FFC0B8; }
#qg.matematica-theme { --subject-title:#FFF9E4; --subject-copy:var(--subject-muted); --subject-tag:#FFE99C; --subject-panel:radial-gradient(ellipse at 94% 2%,#ffd70026,transparent 48%),linear-gradient(150deg,#383018,var(--subject-bg)); --subject-active:linear-gradient(130deg,#6b531b,var(--subject-raised)); box-shadow:0 18px 45px #0004; }
#qg.matematica-theme #qg-title { text-shadow:0 0 24px #ffe27066,0 0 48px #ffb20033; }
#qg.fisica-theme { --physics-title:var(--subject-text); --physics-copy:var(--subject-muted); --physics-tag:var(--subject-accent); --physics-accent:var(--subject-accent); --physics-border:var(--subject-border); --physics-surface:var(--subject-surface); --physics-active:var(--subject-raised); background:linear-gradient(145deg,color-mix(in srgb,var(--subject-secondary) 8%,var(--subject-surface)),var(--subject-bg)); }
#qg:is(.matematica-theme,.fisica-theme) :is(button,a,summary) { min-height:44px; }
#qg:is(.matematica-theme,.fisica-theme) :is(button,a,summary):focus-visible { outline:3px solid var(--subject-focus); outline-offset:4px; }
#qg:is(.matematica-theme,.fisica-theme) button[aria-expanded='true'] { border-style:double; border-width:3px; }
body.portal-theme.study-active,body.portal-theme.study-active:has(#study.algebra-pilot-active) { --study-bg:var(--subject-bg); --study-surface:var(--subject-surface); --study-text:var(--subject-text); --study-muted:var(--subject-muted); --study-edge:var(--subject-border); --study-warm:var(--subject-accent); background:radial-gradient(ellipse at 85% 7%,#ffd7000e,transparent 54%),radial-gradient(ellipse at 5% 75%,#d4a43e08,transparent 60%),var(--subject-bg); color:var(--subject-text); }
body.portal-theme.physics-reading { background:radial-gradient(ellipse at 85% 7%,color-mix(in srgb,var(--subject-secondary) 18%,transparent),transparent 44%),var(--subject-bg); color:var(--subject-text); }
#study,#physics-study { color:var(--subject-text); }
#study :is(.study-title,h1,h2,h3,h4,.math-example summary,.study-heading strong,.other-section-heading h2) { color:var(--subject-text); }
#study :is(.algebra-overline,.basic-kicker,.other-eyebrow,.math-skill,.math-error-count,.study-kicker) { color:var(--subject-accent) !important; font-size:.875rem !important; }
#study :is(.math-path p,.math-path li,.math-example p,.basic-section p,.other-section p,.algebra-lesson p,.mp-lesson p) { font-size:1rem; line-height:1.75; }
#study .math-path .math-lab-reason { font-size:.9375rem !important; }
#study :is(.math-hero-symbol,.math-opening-question,.math-lab-result) { color:var(--subject-accent) !important; }
#study :is(.math-concept,.math-summary) { border-color:var(--subject-accent); }
#study :is(.math-example,.math-summary,.basic-feedback,.math-activity,.other-task) { color:var(--subject-text); }
#study a,#physics-study a { color:var(--subject-accent); text-underline-offset:.2em; }
#study button,#physics-study .ph-page button { color:var(--subject-text); background:var(--subject-raised); border-color:var(--subject-border); }
#study button[aria-pressed='true'],#physics-study .ph-page button[aria-pressed='true'] { color:var(--subject-text); background:var(--subject-raised); border-color:var(--subject-accent); }
#physics-study :is(.ph-reading p,.ph-reading li,.ph-control,.ph-lab-text,.ph-lead,.ph-legend,.ph-page summary) { color:var(--subject-muted); }
#physics-study .ph-model-contract { padding:12px 18px; border:1px solid var(--subject-border); border-radius:10px; margin:18px 0; }
#physics-study .ph-page .review-checkpoint h3 { margin:8px 0; }
:is(#study,#physics-study) :is(button,select,input,textarea,summary) { font:inherit; }
:is(#study,#physics-study) :is(button,select,input:not([type='checkbox']):not([type='radio']),summary) { min-height:44px; }
:is(#study,#physics-study) button { padding:.6rem .85rem; white-space:normal; line-height:1.45; }
#study :is(.math-options,.review-options,.finance-options,.advanced-options,.stats-lab-options) button { color:var(--subject-text); background:var(--subject-raised); border:1px solid var(--subject-border); }
:is(#study,#physics-study) :is(button,select,textarea,input):focus-visible,:is(#study,#physics-study) :is(a,summary):focus-visible { outline:3px solid var(--subject-focus) !important; outline-offset:4px; box-shadow:none; }
@media(hover:hover) { #study :is(.math-options,.review-options) button:hover:not(:disabled) { border-color:var(--subject-accent); text-decoration:underline; text-underline-offset:4px; } }
:is(#study,#physics-study) button[aria-pressed='true'] { border-style:double; border-width:3px; }
:is(#study,#physics-study) :is(button[data-result='true'],button[data-correct='true']) { border-color:var(--subject-ok); }
:is(#study,#physics-study) :is(button[data-result='false'],button[data-correct='false']) { border-style:dashed; border-color:var(--subject-error); }
:is(#study,#physics-study) button:disabled { opacity:.72; cursor:default; border-style:dotted; }
:is(#study,#physics-study) [role='status'] { line-height:1.65; }
:is(#study,#physics-study) :is(input,select,textarea) { max-width:100%; color:var(--subject-text); background:var(--subject-bg); border-color:var(--subject-border); accent-color:var(--subject-accent); }
:is(#study,#physics-study) :is(h1,h2,h3,h4,p,button,summary,li) { overflow-wrap:break-word; }
:is(#study,#physics-study) :is(svg,img) { max-width:100%; }
#physics-study .ph-page { --ph-cyan:var(--subject-accent); --ph-muted:var(--subject-muted); --ph-amber:#E9BC71; color:var(--subject-text); }
#physics-study :is(.ph-kicker,.ph-eyebrow,.ph-header h1,.ph-reading h2,.ph-summary h2,.ph-formula strong) { color:var(--subject-text); }
#physics-study :is(.ph-kicker,.ph-eyebrow) { color:var(--subject-accent); }
.review-theory,.review-explorer,.review-sources,.review-checkpoint { color:var(--subject-text); margin:24px 0 36px; min-width:0; box-sizing:border-box; }
.review-theory { padding:18px 0; background:transparent; border:0; }
.review-explorer,.review-checkpoint { padding:clamp(20px,3vw,32px); border:1px solid color-mix(in srgb,var(--subject-accent) 22%,transparent); border-radius:22px; background:linear-gradient(145deg,color-mix(in srgb,var(--subject-accent) 5%,var(--subject-surface)),var(--subject-bg)); box-shadow:0 12px 30px #00000012; }
.review-sources { padding:18px 0; border:0; border-top:1px solid color-mix(in srgb,var(--subject-accent) 25%,transparent); background:transparent; border-radius:0; }
.review-theory h2,.review-explorer h2 { margin:0 0 16px; }
.review-theory p,.review-explorer p { max-width:78ch; margin:12px 0; }
.review-theory li { margin:.5rem 0; }
.review-kicker { font-size:.875rem !important; letter-spacing:.06em; font-weight:700; color:var(--subject-accent) !important; }
.review-theory details,.review-explorer details,.review-recovery { padding:12px 16px; border:1px solid var(--subject-border); border-radius:10px; margin:16px 0; }
.review-theory summary,.review-sources summary,.review-recovery summary { cursor:pointer; font-weight:650; }
.review-options { display:flex; flex-wrap:wrap; gap:10px; margin:18px 0; }
.review-options button { flex:1 1 150px; }
.review-feedback { min-height:1.7em; }
.review-feedback[data-correct='true'] { color:var(--subject-ok) !important; }
.review-feedback[data-correct='false'] { color:var(--subject-error) !important; }
.review-controls { display:flex; gap:16px; flex-wrap:wrap; margin:20px 0; }
.review-controls label { display:grid; gap:8px; flex:1 1 180px; }
.review-controls :is(select,input) { width:100%; padding:8px 12px; border:1px solid var(--subject-border); border-radius:8px; box-sizing:border-box; }
.review-table-scroll { overflow-x:auto; border:1px solid var(--subject-border); border-radius:8px; margin:18px 0; }
:is(#study,#physics-study) .review-table-scroll table { width:100%; border-collapse:collapse; min-width:300px; color:var(--subject-text); background:var(--subject-bg); font-size:1rem; }
.review-table-scroll :is(th,td) { padding:10px 12px; text-align:left; border-bottom:1px solid var(--subject-border); }
.review-table-scroll th { color:var(--subject-accent); }
.review-table-scroll caption { padding:12px; text-align:left; color:var(--subject-muted); }
.review-outcomes { display:flex; flex-wrap:wrap; gap:8px; list-style:none; padding:0; }
.review-outcomes li { padding:8px 12px; border:1px solid var(--subject-border); border-radius:7px; }
.review-outcomes .is-included { border-width:2px; border-color:var(--subject-accent); background:var(--subject-raised); }
.review-explorer svg { display:block; width:100%; height:auto; color:var(--subject-text); }
.review-explorer svg text { fill:var(--subject-text); font:14px system-ui,sans-serif; }
.review-explorer .review-dot { fill:var(--subject-accent); }
.review-recall { border-left:3px solid var(--subject-accent); padding-left:16px; }
.review-sources { font-size:1rem; }
.review-sources li { margin:.65em 0; }
#study .review-checkpoint { margin:18px 0 30px; padding:18px; border-left:4px solid var(--subject-accent); }
#study .review-checkpoint h3 { font-size:1.0625rem; margin:8px 0; }
@media(max-width:640px) { .review-explorer { padding:18px; } #study .math-goals { grid-template-columns:1fr; } #study .math-examples>div { grid-template-columns:1fr; } .review-controls { gap:12px; } .review-options button { flex-basis:100%; } }
@media(prefers-reduced-motion:reduce) { :is(#study,#physics-study) *, :is(#study,#physics-study) *::before, :is(#study,#physics-study) *::after { animation:none !important; transition:none !important; scroll-behavior:auto !important; } }

/* Leitura aberta; dourado da Matemática em superfícies quentes e discretas. */
#study { background:transparent; }
#study .study-page { background:transparent; }
#study :is(.basic-section,.other-intro,.other-section,.algebra-section,.mp-section) { background:transparent; }
#study :is(.basic-lesson,.other-lesson,.algebra-lesson) { --panel:var(--subject-surface); --panel2:var(--subject-raised); --line:var(--subject-border); --card:var(--subject-surface); --card-light:var(--subject-raised); --edge:var(--subject-border); --al-ink:var(--subject-text); --al-muted:var(--subject-muted); --al-panel:var(--subject-surface); --al-panel-2:var(--subject-raised); --al-line:var(--subject-border); --al-violet:var(--subject-accent); --al-pink:#F2D68D; }
#study.algebra-pilot-active { --algebra-ink:var(--subject-text); --algebra-muted:var(--subject-muted); --algebra-panel:var(--subject-surface); --algebra-line:var(--subject-border); --algebra-violet:var(--subject-accent); --algebra-magenta:#F2D68D; }
#study .study-heading,#study[data-lesson] .study-heading { border-color:#ffd70030; border-left-color:var(--subject-accent); border-radius:24px; background:radial-gradient(ellipse at 90% 0%,#ffd7000d,transparent 62%),linear-gradient(125deg,var(--subject-surface),var(--subject-bg)); box-shadow:0 14px 40px #00000014; }
#study .study-heading h1,#study[data-lesson] .study-heading h1 { color:var(--subject-accent); text-shadow:0 0 28px #ffd70018; }
#study .study-heading::after,#study[data-lesson] .study-heading::after { color:#ffd70016; }
#study .study-heading #study-subtitle,#study[data-lesson] .study-heading #study-subtitle { color:var(--subject-muted); }
#study :is(.math-hero,.algebra-opening,.math-summary,.math-lab,.algebra-live,.math-guided,.math-train,.math-challenge,.algebra-train,.algebra-challenge,.basic-final,.basic-summary,.basic-lab,.basic-workbench,.gallery-workshop,.galaxy-section,.logic-lab,.logic-question,.other-finale,.thought-card,.study-opening,.study-try-system,.study-build,.study-timeline-section,.study-comparison,.study-discovery,.study-closing,.study-challenge) { background:radial-gradient(ellipse at 95% 0%,#ffd7000a,transparent 65%),linear-gradient(135deg,var(--subject-surface),var(--subject-bg)); border:1px solid #ffd7002e; border-radius:22px; box-shadow:0 12px 30px #00000012; }
#study .basic-main .basic-lab { background:linear-gradient(135deg,var(--subject-surface),var(--subject-bg)); }
#study :is(.math-goals,.algebra-objectives,.math-errors,.algebra-errors) { background:transparent; box-shadow:none; border-radius:0; border-color:#ffd70030; }
#study :is(.math-summary,.basic-summary,.other-finale) { border-top:2px solid #ffd70080; }
#study :is(.math-hero-symbol,.math-activity,.math-example,.other-task,.basic-challenge-card,.gallery-person,.gallery-work,.gallery-match-grid>div,.logic-sentence,.thought-steps>div,.thought-analogy,.algebra-note,.algebra-builder,.algebra-slider-wrap,.algebra-substitution,.algebra-meaning-grid article,.algebra-examples details,.algebra-quiz,.algebra-challenge-card,.algebra-error-card,.algebra-next,.study-number-card,.study-try-panel,.study-reveal,.study-timeline-detail,.study-complete-path span) { background:linear-gradient(145deg,var(--subject-raised),var(--subject-surface)); border-color:#ffd70030; border-radius:16px; }
#study .gallery-person { border-color:color-mix(in srgb,var(--tone) 32%,transparent); }
#study :is(.gallery-orbit,.basic-visual,.study-count-visual,.study-record-visual,.study-challenge-visual) { background:radial-gradient(circle at 50% 45%,var(--subject-raised),var(--subject-bg)); border-color:#ffd70030; }
#study :is(.gallery-orbit span,.gallery-portrait,.algebra-mark span,.basic-summary li,.other-reveal,.basic-concept-note,.galaxy-caption,.math-reverse-expression,.algebra-equation,.algebra-built,.math-geometry-figure,.trig-extension-visual-svg) { background:var(--subject-surface); border-color:#ffd70040; }
#study .study-system { background:var(--subject-surface); }
#study .study-system::before { background:radial-gradient(circle at 90% 6%,color-mix(in srgb,var(--accent) 8%,transparent),transparent 65%),var(--subject-surface); }
#study :is(.study-hero-art,.study-build-work,.study-wide-note,.study-numeral,.study-timeline-dot) { background:var(--subject-surface); border-color:#ffd70030; }
#study :is(.basic-feedback,.math-feedback,.math-reverse-feedback,.algebra-insight) { background:transparent; }
#study .algebra-action-primary { background:var(--subject-raised) !important; border-color:var(--subject-border) !important; }
#study .algebra-action-primary:hover { background:var(--subject-surface) !important; }
#study :is(button,.other-button,.basic-button) { background:var(--subject-raised); color:var(--subject-text); border-color:var(--subject-border); }
#study :is(button,.other-button,.basic-button):hover:not(:disabled) { background:var(--subject-surface); color:var(--subject-text); border-color:var(--subject-accent); }
#study :is(button,.other-button,.basic-button)[aria-pressed='true'] { background:var(--subject-raised); color:var(--subject-text); border-color:var(--subject-accent); }
#study :is(.algebra-progress-track span,.study-timeline-progress span,.study-challenge-progress .current,.study-challenge-progress .done) { background:var(--subject-accent); }
#study :is(.study-back,.study-central,.study-end-nav a) { color:var(--subject-muted); }

/* Física: evitar caixas planas em textos e apoiar os experimentos em cartões suaves. */
#physics-study :is(.ph-errors,.ph-activity,.ph-formula) { background:transparent; border-color:color-mix(in srgb,var(--subject-accent) 45%,transparent); }
#physics-study .ph-errors { border-left-color:#E9BC71; }
#physics-study .ph-activity { padding-inline:0; }
#physics-study :is(.ph-lab,.ph-summary,.ph-goals,.ph-reading.ph-intro-panel,.ph-journey,.ph-model-contract) { background:radial-gradient(ellipse at 95% 0%,#54d7e50c,transparent 64%),linear-gradient(135deg,var(--subject-surface),var(--subject-bg)); border:1px solid #54d7e538; border-radius:22px; box-shadow:0 12px 30px #00000014; }
#physics-study .ph-lesson.ph-discovery-lesson > .ph-reading.ph-intro-panel { border-left:1px solid #54d7e538; }
#physics-study :is(.ph-summary,.ph-goals) { border-top:2px solid #54d7e566; }
#physics-study :is(.ph-note,.ph-examples details,.ph-topic-accordions details,.ph-scene-readout,.ph-record-block) { background:linear-gradient(135deg,#54d7e507,var(--subject-surface)); border-color:#54d7e530; border-radius:16px; }
#physics-study .ph-note { border-left-color:var(--subject-accent); }
#physics-study .ph-header { border-radius:24px; border-color:#54d7e530; box-shadow:0 14px 40px #00000014; }
:is(#study,#physics-study) :is(.review-theory,.review-sources) { box-shadow:none; }
@media(max-width:640px) { #study .study-heading,#study[data-lesson] .study-heading { border-radius:20px; } #physics-study :is(.ph-lab,.ph-summary,.ph-goals,.ph-reading.ph-intro-panel,.ph-journey) { border-radius:18px; } }

#study[data-lesson="history"] .study-heading { background:transparent; box-shadow:none; border-radius:0; }
/* Superfícies das demais famílias de aulas, mantendo cores dos diagramas. */
#study :is(.mp-opening,.mp-lab,.mp-guided,.mp-train,.mp-challenge,.mp-summary,.finance-exploration,.stats-exploration,.exponential-explorer) { background:linear-gradient(135deg,var(--subject-surface),var(--subject-bg)); border-color:#ffd70030; border-radius:22px; box-shadow:0 12px 30px #00000012; }
#study :is(.mp-objectives,.mp-errors) { background:transparent; border-color:#ffd70030; }
#study :is(.mp-quiz,.mp-examples details,.mp-result,.math-story,.math-model-story,.math-machine-result,.exp-readout,.dataset-display) { background:var(--subject-surface); border-color:#ffd70030; }
#study .basic-expanded :is(.xb-panel,.xb-example,.xb-mistakes details,.xb-practice,.xb-three>div),#study .basic-deep :is(.deep-visual-panel,.deep-lab,.deep-properties,.deep-optional) { background:linear-gradient(135deg,var(--subject-surface),var(--subject-bg)); border-color:#ffd70030; border-radius:20px; }
#study .basic-expanded :is(.xb-goals,.xb-summary-section),#study .basic-deep .deep-goals { background:transparent; border-color:#ffd70030; }
#study .basic-expanded :is(.xb-note,.xb-discovery,.xb-example-steps>p,.xb-summary-grid li),#study .basic-deep :is(.deep-inline-note,.deep-discovery,.deep-warning) { background:var(--subject-surface); border-color:#ffd70040; }
#study .basic-ops :is(.ops-activity,.ops-context-answer,.ops-opening-art,.ops-orbit,.ops-pills span) { background:var(--subject-surface); border-color:#ffd70030; }
/* State repair: lesson controls follow the subject, including older hover rules. */
#study button:not(:disabled):is(:hover,[aria-pressed='true']) { background:var(--subject-raised)!important;color:var(--subject-text)!important; }
#study button:not(:disabled):hover:not([data-result]):not([data-correct]) { border-color:var(--subject-accent); }
#study input[type='range'] { accent-color:var(--subject-accent)!important; }
#study .exp-base-control output { color:var(--subject-accent); }
#study .exp-graph-wrap { background:var(--subject-bg);border-color:#ffd70030; }
#study .exp-curve { stroke:var(--subject-accent); }
#study .exp-linear { stroke:#54d7e5;stroke-width:3;fill:none;stroke-dasharray:7 5; }
#study [data-exp-grid] { fill:var(--subject-muted);font:14px system-ui,sans-serif; }
#study .exp-readout { background:var(--subject-surface);border-color:var(--subject-accent); }
#study .exp-compare-control { display:flex;align-items:center;gap:12px;margin:20px 0;line-height:1.6; }
#study .exp-compare-control input { width:22px;height:22px;min-height:22px;flex:none; }
#physics-study .ph-page button:hover:not(:disabled) { background:var(--subject-raised);border-color:var(--subject-accent); }
#physics-study .ph-page button[aria-pressed='true'] { background:var(--subject-raised);border-color:var(--subject-accent); }
@media(max-width:640px) { #study [data-exp-grid] { font-size:18px; } }
#study button[aria-pressed='true'] { background:var(--subject-raised)!important;color:var(--subject-text)!important; }
#study button:disabled { background:var(--subject-surface)!important;color:var(--subject-muted)!important; }
#physics-study button:not(:disabled):is(:hover,[aria-pressed='true']) { background:var(--subject-raised)!important; }
