/* MATHVERSE CAT v8.3 — dia, nit i mode automàtic. No s'alteren les gràfiques científiques. */
:root{color-scheme:dark}
html[data-theme="light"]{color-scheme:light;--bg:#f0f6ff;--panel:#fff;--panel2:#edf4ff;--border:#c6d6eb;--text:#152740;--muted:#526681;--teal:#006d68;--violet:#654fbb;--gold:#946015;--pink:#a52c67;--blue:#0b5caa;--danger:#a12f48;--shadow:0 18px 55px rgba(35,65,113,.10)}
.theme-toggle{display:inline-flex;align-items:center;justify-content:center;gap:6px;vertical-align:middle;font-weight:850;white-space:nowrap;touch-action:manipulation}
.theme-toggle:focus-visible{outline:3px solid #c48d19;outline-offset:3px}
.theme-toggle .theme-icon{font-size:22px;line-height:1}
.theme-toggle .theme-label{font-size:12px;font-weight:800}
.top-actions .theme-toggle{flex:0 0 auto}
.learn-theme-toggle{min-height:42px;padding:8px 11px;background:#172746;color:#fff;border-radius:11px;border:1px solid #829bbf;cursor:pointer}
html[data-theme="light"] .learn-theme-toggle{color:#1a2d4f;background:#fff;border-color:#a7bfdd}
html[data-theme="light"] body{background:#f0f6ff;color:var(--text)}
html[data-theme="light"] body:before{background:linear-gradient(180deg,transparent 30%,#f0f6ff 100%)}
html[data-theme="light"] #space{opacity:.09}
html[data-theme="light"] .ambient{opacity:.08}
html[data-theme="light"] .brand-copy small,html[data-theme="light"] .conn{color:#526580}
html[data-theme="light"] .icon-btn,html[data-theme="light"] .xp-pill,html[data-theme="light"] .ghost-btn{background:#fff;border-color:#b6cbe5;color:#263d5c}
html[data-theme="light"] .xp-pill{color:#86540b}
html[data-theme="light"] h1 .gradient,html[data-theme="light"] .gradient{background:linear-gradient(90deg,#152740,#087d81,#5c4b9e);background-clip:text;-webkit-background-clip:text;color:transparent}
html[data-theme="light"] .hero p,html[data-theme="light"] .muted,html[data-theme="light"] .section-head p{color:#526681}
html[data-theme="light"] .metric,html[data-theme="light"] .panel,html[data-theme="light"] .mission-card,html[data-theme="light"] .side-panel,html[data-theme="light"] .guide-card{background:#fff;border-color:#c8d6e9;color:#152740;box-shadow:0 12px 36px rgba(42,68,103,.07)}
html[data-theme="light"] .metric span,html[data-theme="light"] .world-body p,html[data-theme="light"] .guide-card p,html[data-theme="light"] .footer,html[data-theme="light"] .small-note,html[data-theme="light"] .history-row span,html[data-theme="light"] .site-credit,html[data-theme="light"] .seo-resources,html[data-theme="light"] .seo-entry{color:#516480}
html[data-theme="light"] .world{background:#fff;border-color:#bbcee6;color:#142841;box-shadow:0 10px 28px rgba(49,74,115,.09)}
html[data-theme="light"] .world:hover{box-shadow:0 13px 35px rgba(49,74,115,.17)}
html[data-theme="light"] .world-body h3,html[data-theme="light"] .world-body,html[data-theme="light"] .world-meta{color:#172b49}
html[data-theme="light"] .world-visual,html[data-theme="light"] .float-chip{color:#f6faff}
html[data-theme="light"] .float-chip{background:rgba(20,35,69,.9)}
html[data-theme="light"] .config label,html[data-theme="light"] .input-label,html[data-theme="light"] .game-head p,html[data-theme="light"] .challenge-instruction{color:#47617f}
html[data-theme="light"] .select,html[data-theme="light"] .filters input,html[data-theme="light"] .filters select,html[data-theme="light"] .input-group input,html[data-theme="light"] .input-group textarea,html[data-theme="light"] .num-control input{background:#f8fbff;color:#142740;border-color:#b7c9e3}
html[data-theme="light"] .btn.secondary,html[data-theme="light"] .btn.soft{background:#e8f2ff;border-color:#bbcee7;color:#143956}
html[data-theme="light"] .btn{box-shadow:0 7px 17px rgba(15,115,140,.12)}
html[data-theme="light"] .pill,html[data-theme="light"] .game-badge,html[data-theme="light"] .mini-tag{background:#e9f1fb;color:#315179;border-color:#c1d2e7}
html[data-theme="light"] .dock{background:rgba(255,255,255,.96);border-color:#bccfe7;box-shadow:0 9px 30px rgba(20,44,74,.14)}
html[data-theme="light"] .dock button{color:#506583}
html[data-theme="light"] .dock button.active{background:#dff3f0;color:#075f62}
html[data-theme="light"] .top-link,html[data-theme="light"] .resource-box h4{color:#096a79}
html[data-theme="light"] .tally,html[data-theme="light"] .separator,html[data-theme="light"] .history-row{border-color:#c8d6e9}
html[data-theme="light"] .side-panel p,html[data-theme="light"] .side-panel li,html[data-theme="light"] .resource-box p{color:#506580}
html[data-theme="light"] .readout,html[data-theme="light"] .interact-readout,html[data-theme="light"] .resource-box,html[data-theme="light"] .insight,html[data-theme="light"] .breakdown,html[data-theme="light"] .quote-card,html[data-theme="light"] .mini-demo{background:#edf4fd;color:#233d60;border-color:#cfdded}
html[data-theme="light"] .readout small{color:#4b6681}
html[data-theme="light"] .method-check label,html[data-theme="light"] .choice,html[data-theme="light"] .beat,html[data-theme="light"] .robot-pad button{background:#f0f5fd;color:#1b3556;border-color:#b6cae0}
html[data-theme="light"] .choice.selected,html[data-theme="light"] .choice:hover,html[data-theme="light"] .beat.on{background:#d9f3ee;color:#0e5c60;border-color:#228884}
html[data-theme="light"] .finale,html[data-theme="light"] .levelbar{color:#193553}
html[data-theme="light"] .feedback{background:#e1f5e9;color:#205b47;border-color:#93d4ae}
html[data-theme="light"] .feedback.err{background:#fff0ef;color:#983842;border-color:#e7b3bc}
html[data-theme="light"] .feedback strong{color:inherit}
html[data-theme="light"] .site-credit{border-color:#c9d6e9}
html[data-theme="light"] .site-credit strong{color:#213959}
html[data-theme="light"] .seo-resources{border-color:#c9d6e9}
html[data-theme="light"] .seo-resources a,html[data-theme="light"] .seo-entry a{color:#0b6c71}
html[data-theme="light"] .toast{background:#193756;color:#fff}
html[data-theme="light"] .fn-home-banner,html[data-theme="light"] .calc-homebanner,html[data-theme="light"] .calc-curriculum,html[data-theme="light"] .frac-home-banner,html[data-theme="light"] .ps-homebanner{background:linear-gradient(125deg,#e2efff,#f0eafe);color:#1c3554;border-color:#c0d4ee;box-shadow:0 12px 33px rgba(49,74,115,.08)}
html[data-theme="light"] .fn-home-banner p,html[data-theme="light"] .calc-homebanner p,html[data-theme="light"] .calc-header p,html[data-theme="light"] .frac-home-banner p,html[data-theme="light"] .ps-homebanner p{color:#49617d}
html[data-theme="light"] .ps-homebanner h2{color:#233858}
html[data-theme="light"] .fn-editor-label,html[data-theme="light"] .fn-cursor-label,html[data-theme="light"] .frac-answer-caption,html[data-theme="light"] .frac-input-label{color:#23415d}
html[data-theme="light"] .fn-expression,html[data-theme="light"] .frac-input,html[data-theme="light"] .calc-editor input{background:#f8fbff;color:#18304b;border-color:#9fb9d8}
/* Els gràfics vectorials tenen colors pensats per a un fons fosc: no invertir-los. */
html[data-theme="light"] .game-surface,html[data-theme="light"] .surreal-stage,html[data-theme="light"] .frac-stage,html[data-theme="light"] .fn-graph-panel,html[data-theme="light"] .ps-board,html[data-theme="light"] .lab-surface{background:#0e1d3d;color:#e8f3ff;border-color:#6b86ac}
html[data-theme="light"] .fn-graph-panel .fn-graph-heading,html[data-theme="light"] .fn-graph-panel .fn-readout,html[data-theme="light"] .fn-graph-panel .fn-gesture,html[data-theme="light"] .fn-graph-panel .fn-graph-heading span,html[data-theme="light"] .fn-graph-panel .fn-cursor-label,html[data-theme="light"] .fn-graph-panel .fn-cursor-label strong{color:#e8f7ff}
html[data-theme="light"] .fn-table-wrap,html[data-theme="light"] .fn-help{background:#eef6ff;border-color:#bfd1e6;color:#25425d}
html[data-theme="light"] .fn-table-scroll th{color:#076e72}
html[data-theme="light"] .fn-help code{color:#075d61}
html[data-theme="light"] .calc-catalog,html[data-theme="light"] .calc-card{background:#fff;color:#172b49;border-color:#c2d3ea;box-shadow:0 10px 35px rgba(49,73,110,.09)}
html[data-theme="light"] .calc-catalog h3,html[data-theme="light"] .calc-card>p,html[data-theme="light"] .calc-progress{color:#2e4563}
html[data-theme="light"] .calc-chapter{color:#304b6a}
html[data-theme="light"] .calc-chapter>span:first-child{background:#e2edfa;color:#095e69}
html[data-theme="light"] .calc-chapter small{color:#536c88}
html[data-theme="light"] .calc-chapter.selected{background:#ddf4f0;color:#0a5b61;border-color:#77beb4}
html[data-theme="light"] .calc-chapter:hover{background:#edf4fc}
html[data-theme="light"] .calc-tabs button{background:#edf3fd;color:#385574;border-color:#c2d4e9}
html[data-theme="light"] .calc-tabs button.active{background:#08727d;color:#fff;border-color:#08727d}
html[data-theme="light"] .calc-formula,html[data-theme="light"] .calc-tutorial,html[data-theme="light"] .calc-practice,html[data-theme="light"] .calc-step,html[data-theme="light"] .calc-explain{background:#ecf4ff;color:#193756;border-color:#c3d5ed}
html[data-theme="light"] .calc-explain strong{color:#18304d}
html[data-theme="light"] .calc-equation{color:#096a70}
html[data-theme="light"] .calc-legend,html[data-theme="light"] .calc-graph label{color:#294765}
html[data-theme="light"] .calc-coordinates{background:#dcedf8;color:#193b59}
html[data-theme="light"] .calc-dots button{background:#b0c5df;border-color:#819bb9}
html[data-theme="light"] .calc-dots button.active{background:#058e8b;border-color:#027572}
html[data-theme="light"] .calc-victory{background:#e0f5ec;color:#1e5944}
html[data-theme="light"] .calc-victory h3{color:#1d6a51}
html[data-theme="light"] .calc-message.ok{background:#e1f5eb;color:#176046}
html[data-theme="light"] .calc-message.not-ok{background:#fff1ee;color:#8f343b}
html[data-theme="light"] .ps-context,html[data-theme="light"] .ps-inspector,html[data-theme="light"] .ps-weights{background:#e8f4fb;color:#23425d;border-color:#c0d8e7}
html[data-theme="light"] .ps-context p,html[data-theme="light"] .ps-weights label,html[data-theme="light"] .ps-answerlabel{color:#23435e}
html[data-theme="light"] .ps-weights strong{color:#096b74}
html[data-theme="light"] .ps-option,html[data-theme="light"] .ps-pair-cards>div,html[data-theme="light"] .ps-post,html[data-theme="light"] .ps-values span{background:#e9f2fd;color:#163854;border-color:#a6c4dd}
html[data-theme="light"] .ps-option.ps-selected{background:#d8f4ed;color:#075b5d;border-color:#33a098}
html[data-theme="light"] .ps-post p,html[data-theme="light"] .ps-pair-cards p,html[data-theme="light"] .ps-values small{color:#4a6481}
html[data-theme="light"] .ps-mini-metrics>div,html[data-theme="light"] .ps-sim-result,html[data-theme="light"] .ps-score{color:#25506c!important}
html[data-theme="light"] .tutor-dialog{background:#fff;color:#1b3351;border-color:#c0d3e9}
html[data-theme="light"] .tutor-stage-content,html[data-theme="light"] .tutor-stage-content p,html[data-theme="light"] .tutor-dialog h2,html[data-theme="light"] .tutor-gamebar strong{color:#203956}
html[data-theme="light"] .tutor-notes,html[data-theme="light"] .tutor-formula,html[data-theme="light"] .tutor-question,html[data-theme="light"] .tutor-chip{background:#edf4fd;color:#203e5a;border-color:#c5d5e8}
html[data-theme="light"] .tutor-notes strong,html[data-theme="light"] .tutor-notes p{color:#294865}
html[data-theme="light"] .tutor-answer{background:#eef4fd;color:#183856;border-color:#b6cce4}
html[data-theme="light"] .tutor-answer.selected,html[data-theme="light"] .tutor-answer:hover{background:#d9f0eb;color:#075e63;border-color:#38a7a0}
html[data-theme="light"] .tutor-gamebar{background:#eff6fd;color:#213c58;border-color:#c5d6eb}
html[data-theme="light"] .tutor-gamebar span{color:#42627d}
html[data-theme="light"] .tutor-cross{background:#e5edf8;color:#1d3755}
/* Recursos informatius indexables */
html[data-theme="light"] body:has(.site-top){background:radial-gradient(ellipse at 75% -10%,#e1ecfc 0,transparent 36%),radial-gradient(ellipse at 2% 40%,#e9efff 0,transparent 50%),#f5f8ff;color:#152b46}
html[data-theme="light"] body:has(.site-top) a{color:#066d6c}
html[data-theme="light"] body:has(.site-top) a:hover{color:#134e7a}
html[data-theme="light"] .site-top{background:rgba(255,255,255,.93);border-color:#cfdaeb}
html[data-theme="light"] .logo{color:#1d3554}
html[data-theme="light"] .logo span{color:#087e7a}
html[data-theme="light"] .topline nav a,html[data-theme="light"] .crumb{color:#466481}
html[data-theme="light"] .eyebrow{color:#086e70}
html[data-theme="light"] .lead,html[data-theme="light"] .lesson p,html[data-theme="light"] .box p{color:#3c5471}
html[data-theme="light"] .box{background:#fff;color:#203651;border-color:#c7d5eb;box-shadow:0 8px 28px rgba(40,65,100,.07)}
html[data-theme="light"] .related,html[data-theme="light"] .foot{border-color:#c9d7e8}
html[data-theme="light"] .related-links a{background:#e8f1fc;border-color:#baccdf}
html[data-theme="light"] .foot,html[data-theme="light"] .fine{color:#4a617d!important}
@media(max-width:435px){.topbar:has(.theme-toggle){flex-wrap:wrap;gap:7px}.topbar .top-actions:has(.theme-toggle){margin-left:auto}.topbar .top-actions .icon-btn{width:38px;height:38px;padding:6px}.topbar .top-actions .xp-pill{padding:8px}.topline nav{align-items:center}.learn-theme-toggle{min-height:37px}}
@media(prefers-reduced-motion:reduce){.theme-toggle{transition:none!important}}
/* Formularis de fraccions: el tauler de representació resta fosc, però l'entrada és clara. */
html[data-theme="light"] .frac-workspace,html[data-theme="light"] .frac-tools,html[data-theme="light"] .frac-preview{background:#f0f6ff;border-color:#bfd2e8;color:#24415e}
html[data-theme="light"] .frac-preview,html[data-theme="light"] .frac-tools p{color:#2a5068}
html[data-theme="light"] .frac-tools summary{color:#086c70}
html[data-theme="light"] .frac-answer-line{background:#107f77}
/* Tutorial en mode clar amb interacció i resposta correcta clarament identificades. */
html[data-theme="light"] .tutor-gamebar{background:linear-gradient(120deg,#eaf2fc,#e0f2ef);border-color:#b9d2e1}
html[data-theme="light"] .tutor-answer.correct{color:#13563b;background:#d1f4e1;border-color:#49ac80}
html[data-theme="light"] .tutor-answer-feedback,html[data-theme="light"] .tutor-answer-feedback strong{color:#29425c}
html[data-theme="light"] .tutor-stage-meta{color:#096d70}
html[data-theme="light"] .tutor-skip{color:#4d637e}
html[data-theme="light"] .calc-live-slope strong{color:#a96010}
html[data-theme="light"] .calc-live-equation strong{color:#705410}
