/* Todo seletor está restrito ao novo núcleo. */
:is(#study.ds-active,#qg.ds-hub){--ds-gold:#f0ce83;--ds-text:#f5efe0;--ds-muted:#d2ccbf;--ds-line:#c9ab6255;--ds-violet:#c6b0ec;--ds-blue:#a2ced8;color:var(--ds-text)}
#qg.ds-hub #qg-view{display:block}
#qg.ds-hub .ds-block{margin:2.2rem 0 3rem;border-top:1px solid var(--ds-line);padding-top:1.4rem}
#qg.ds-hub .ds-block h3{font:600 clamp(1.3rem,3vw,1.8rem)/1.35 Georgia,serif;color:var(--ds-gold);margin:0 0 .6rem}
#qg.ds-hub .ds-block>p{color:var(--ds-muted);line-height:1.65;max-width:70ch}
#qg.ds-hub .ds-links{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,340px),1fr));gap:.7rem 1.4rem;margin-top:1.3rem}
#qg.ds-hub .ds-course{display:grid;gap:.6rem;align-content:start;padding:1.2rem;border:1px solid var(--ds-line);border-radius:.7rem;color:var(--ds-text);text-decoration:none;background:#23282370;line-height:1.5;min-width:0}
#qg.ds-hub .ds-course span{font-size:.9rem;color:var(--ds-muted)}
#qg.ds-hub .ds-course em{font-style:normal;color:var(--ds-gold);font-size:.85rem}
#qg.ds-hub .ds-course:hover{background:#383727;border-color:var(--ds-gold)}
#study.ds-active .study-heading{padding:clamp(1.3rem,4vw,2.7rem);margin-bottom:2.5rem;background:linear-gradient(125deg,#292a24,#20272b);border:1px solid var(--ds-line);border-radius:1rem;box-shadow:none}
#study.ds-active .study-heading::after{display:none}
#study.ds-active .study-heading h1{font:600 clamp(1.8rem,4vw,2.8rem)/1.22 Georgia,serif;color:var(--ds-gold)}
#study.ds-active .study-kicker,#study.ds-active .study-index{display:none}
#study.ds-active .ds-lesson{max-width:1020px;margin:auto;font-size:1.03rem;line-height:1.8;overflow-wrap:anywhere}
#study.ds-active .ds-lesson p{color:var(--ds-muted);max-width:80ch;margin:.8rem 0}
#study.ds-active .ds-lesson h2{font:600 clamp(1.4rem,3vw,1.85rem)/1.3 Georgia,serif;margin:2.2rem 0 1rem;color:var(--ds-text)}
#study.ds-active .ds-lesson h3{font:600 1.18rem/1.4 system-ui,sans-serif;color:var(--ds-gold);margin:1.3rem 0 .6rem}
#study.ds-active .ds-formula{padding:1rem 1.2rem;margin:1.4rem 0;border-left:3px solid var(--ds-gold);background:#36342855;font:500 clamp(1.1rem,2.2vw,1.35rem)/1.7 Georgia,serif;overflow-x:auto;max-width:100%}
#study.ds-active .ds-worked{margin:1.8rem 0;padding-left:1.3rem;border-left:1px solid var(--ds-line)}
#study.ds-active .ds-note{border-top:1px dashed var(--ds-line);padding-top:.8rem}
#study.ds-active .ds-bridge{font-size:.9rem;color:var(--ds-blue)!important}
#study.ds-active a{color:var(--ds-gold)}
#study.ds-active .ds-lab{border:1px solid var(--ds-line);border-radius:1rem;background:#19252b;padding:clamp(1rem,3vw,1.8rem);margin:2.5rem 0;min-width:0}
#study.ds-active .ds-lab h2{margin:0 0 .6rem;color:var(--ds-gold)}
#study.ds-active .ds-controls{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,170px),1fr));gap:1rem;margin:1.2rem 0}
#study.ds-active .ds-controls label{display:flex;flex-direction:column;gap:.4rem;font-size:.92rem;color:var(--ds-text);min-width:0}
#study.ds-active .ds-wide{grid-column:1/-1}
#study.ds-active :is(.ds-lab,.ds-practice) :is(input,select,button){font:inherit;min-height:44px;max-width:100%;border:1px solid var(--ds-line);border-radius:.4rem;padding:.55rem .7rem;background:#253239;color:var(--ds-text);box-sizing:border-box}
#study.ds-active .ds-lab :is(input,select){width:100%;min-width:0}
#study.ds-active button{cursor:pointer}
#study.ds-active button:hover{background:#43402c}
#study.ds-active [aria-invalid=true]{border-color:#ffbfb6!important}
#study.ds-active .ds-actions{display:flex;gap:.7rem;flex-wrap:wrap;margin:1rem 0}
#study.ds-active .ds-validation{color:#ffbfb6!important;min-height:1.5em}
#study.ds-active .ds-output{min-width:0}
#study.ds-active .ds-output dl{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,170px),1fr));gap:1rem}
#study.ds-active .ds-output dt{color:var(--ds-muted);font-size:.9rem}
#study.ds-active .ds-output dd{margin:.3rem 0;color:var(--ds-gold);font-variant-numeric:tabular-nums}
#study.ds-active .ds-graph{width:100%;height:auto;max-height:520px;background:#17242d;border-radius:.5rem;display:block}
#study.ds-active .ds-graph text{font:16px system-ui,sans-serif;fill:#d2ccbf}
#study.ds-active .ds-grid{stroke:#a2ced822;stroke-width:1;fill:none}
#study.ds-active .ds-axis{stroke:#a5b8c0;stroke-width:1.4;fill:none}
#study.ds-active .ds-line0{stroke:var(--ds-gold);stroke-width:3;fill:none}
#study.ds-active .ds-line1{stroke:var(--ds-violet);stroke-width:3;stroke-dasharray:8 5;fill:none}
#study.ds-active .ds-line2{stroke:var(--ds-blue);stroke-width:2;stroke-dasharray:3 5;fill:none}
#study.ds-active .ds-point0{fill:var(--ds-gold);stroke:#17242d;stroke-width:2}
#study.ds-active .ds-point1{fill:var(--ds-violet);stroke:#17242d;stroke-width:2}
#study.ds-active .ds-table{overflow:auto;max-height:30rem;border:1px solid var(--ds-line);border-radius:.4rem;margin:1rem 0}
#study.ds-active table{border-collapse:collapse;min-width:100%;font-variant-numeric:tabular-nums;font-size:.92rem}
#study.ds-active :is(th,td){padding:.55rem .8rem;text-align:left;white-space:nowrap;border-bottom:1px solid var(--ds-line)}
#study.ds-active th{color:var(--ds-gold)}
#study.ds-active caption{text-align:left;padding:.7rem;background:#253239;color:var(--ds-text)}
#study.ds-active .ds-matrix{display:inline-grid;gap:.2rem .9rem;border-left:2px solid var(--ds-text);border-right:2px solid var(--ds-text);padding:.5rem .8rem;vertical-align:middle;font-variant-numeric:tabular-nums;line-height:1.5;max-width:100%;overflow-x:auto}
#study.ds-active .ds-practice{margin:2.5rem 0}
#study.ds-active .ds-question{border-top:1px solid var(--ds-line);padding:1.1rem 0}
#study.ds-active .ds-question details{margin:.7rem 0}
#study.ds-active summary{cursor:pointer;min-height:36px;color:var(--ds-gold)}
#study.ds-active .ds-answer-feedback{color:var(--ds-blue)!important}
#study.ds-active .ds-investigate{border-top:1px dashed var(--ds-line);margin:2rem 0;padding-top:1rem}
#study.ds-active .ds-nav{display:flex;justify-content:space-between;gap:1rem;flex-wrap:wrap;margin:2.5rem 0}
#study.ds-active .mp-navigation{display:flex;justify-content:space-between;gap:1rem;flex-wrap:wrap;margin:2.5rem 0;min-width:0}
#study.ds-active .mp-navigation a{color:var(--ds-gold);white-space:normal;max-width:100%;line-height:1.5;padding:.8rem;border:1px solid var(--ds-line);border-radius:.5rem}
#study.ds-active :is(.study-back,.study-central){color:var(--ds-gold);min-height:44px}
#qg.ds-hub .section-nav-back{width:auto;min-width:5rem;height:2.75rem;margin-top:0;padding:0 1rem;border:1px solid var(--ds-line);border-radius:.5rem;clip-path:none;background:#2b2b20;box-shadow:none;filter:none}
#qg.ds-hub .section-nav-back::before{content:'Voltar';font:600 .875rem system-ui,sans-serif;color:var(--ds-gold)}
#qg.ds-hub .section-nav-back:hover{transform:none;background:#3b3826;filter:none}
:is(#study.ds-active,#qg.ds-hub) :is(a,button,input,select,summary,[tabindex]):focus-visible{outline:3px solid #ffe2a7;outline-offset:3px}
#qg.matematica-theme .ds-category-card strong{ text-transform:none }
@media(max-width:600px){#study.ds-active .ds-lesson{font-size:1rem}#study.ds-active .ds-worked{padding-left:.8rem}#study.ds-active .ds-lab{padding:1rem}#study.ds-active .ds-actions button{flex:1 1 130px}#study.ds-active .ds-nav a{max-width:100%}}
@media(prefers-reduced-motion:reduce){:is(#study.ds-active,#qg.ds-hub) *{scroll-behavior:auto!important;animation:none!important;transition:none!important}}
/* Resoluções e investigações da v178: mantém o mapa de cinco blocos. */
#study.ds-active .ds-reasoning{padding-left:1.65rem;margin:1rem 0;max-width:85ch}
#study.ds-active .ds-reasoning li{padding:.4rem 0 .6rem .25rem;color:var(--ds-muted);line-height:1.85}
#study.ds-active .ds-reasoning li::marker{color:var(--ds-gold);font-weight:600}
#study.ds-active .ds-inquiry{margin-top:2rem;padding-top:1.3rem;border-top:1px dashed var(--ds-line);min-width:0}
#study.ds-active .ds-inquiry textarea{width:100%;min-height:7rem;font:inherit;line-height:1.7;padding:.7rem;border:1px solid var(--ds-line);border-radius:.4rem;background:#253239;color:var(--ds-text);box-sizing:border-box;resize:vertical}
#study.ds-active .ds-inquiry [data-feedback]{border-left:2px solid var(--ds-gold);padding-left:1rem;color:var(--ds-blue)}
#study.ds-active .ds-inquiry [role=status]{min-height:1.6em}
#study.ds-active .ds-matrix{margin:.2rem;white-space:nowrap;vertical-align:middle}
#study.ds-active .ds-lab label:has([data-target]){display:grid;gap:.5rem;max-width:25rem;margin:1rem 0}
#study.ds-active .ds-lab [data-target]{min-height:44px;font:inherit;padding:.55rem;background:#253239;color:var(--ds-text);border:1px solid var(--ds-line);border-radius:.4rem;max-width:100%}
#study.ds-active :is(textarea,[data-target]):focus-visible{outline:3px solid #ffe2a7;outline-offset:3px}
#study.ds-active .ds-lab .ds-controls label small{color:var(--ds-muted);font-size:.78rem}
@media(max-width:600px){#study.ds-active .ds-reasoning{padding-left:1.4rem}#study.ds-active .ds-matrix{gap:.2rem .5rem;padding:.4rem .5rem}}
/* v179: edição matemática local; estrutura do mapa preservada. */
#study.ds-active :is(.ds-power,.ds-index){font-size:.78em;line-height:0;position:relative;vertical-align:baseline}
#study.ds-active .ds-power{top:-.52em}
#study.ds-active .ds-index{top:.25em}
#study.ds-active .ds-fraction{display:inline-grid;grid-template-rows:auto auto;vertical-align:-.45em;text-align:center;line-height:1.15;font-size:.94em;margin:0 .12em;white-space:nowrap}
#study.ds-active .ds-fraction>span:first-child{border-bottom:1px solid currentColor;padding:0 .18em .12em}
#study.ds-active .ds-fraction>span:last-child{padding:.12em .18em 0}
#study.ds-active :is(.ds-power,.ds-index) .ds-fraction{font-size:.95em;vertical-align:-.4em;line-height:1.05}
#study.ds-active .ds-typeset{overflow-wrap:normal}
#study.ds-active .ds-matrix{position:relative;box-sizing:border-box;min-width:0;overflow-wrap:normal}
#study.ds-active .ds-matrix::before,#study.ds-active .ds-matrix::after{content:'';position:absolute;top:0;bottom:0;width:.35rem;border-top:2px solid var(--ds-text);border-bottom:2px solid var(--ds-text);pointer-events:none}
#study.ds-active .ds-matrix::before{left:0}
#study.ds-active .ds-matrix::after{right:0}
#study.ds-active .ds-matrix .ds-aug-column{border-left:1px solid var(--ds-text);padding-left:.65rem;margin-left:-.25rem}
#study.ds-active .ds-plot{min-width:0;max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;margin:.8rem 0;border-radius:.5rem}
#study.ds-active .ds-plot:focus-visible,#study.ds-active .ds-formula:focus-visible,#study.ds-active .ds-matrix:focus-visible{outline:3px solid #ffe2a7;outline-offset:2px}
#study.ds-active .ds-formula{box-sizing:border-box;min-width:0;overscroll-behavior-x:contain}
#study.ds-active .ds-system{display:grid;gap:.3rem;border-left:2px solid var(--ds-gold);padding:.6rem 1rem;margin:.8rem 0;overflow-x:auto;max-width:100%;box-sizing:border-box}
#study.ds-active .ds-system>span{white-space:nowrap}
@media(max-width:600px){#study.ds-active .ds-plot .ds-graph{min-width:540px;max-height:none}#study.ds-active .ds-reasoning li{line-height:1.95}#study.ds-active .ds-formula{white-space:nowrap}}
