/* Tensora V40 — editorial graphite / sage interface, no gradients or neon. */
:root{color-scheme:light;--v40-shadow:0 12px 38px rgba(18,37,31,.06)}
html[data-theme="dark"]{color-scheme:dark;--ink:#111b1a;--deep:#0e1817;--deep2:#172624;--paper:#111917;--card:#1a2522;--card2:#1e2a26;--border:#31413b;--line:#31413b;--text:#e9eee8;--muted:#afbeb5;--green:#9bc6ae;--greenlight:#243e33;--copper:#cda18a;--navtext:#aabdb5;--surface:#1a2522;--panel:#1a2522;--bg-soft:#23332c;--text-muted:#9fb5a6;--accent:#9bc6ae;--v40-shadow:0 16px 45px rgba(0,0,0,.17)}
.shell .work-area,.shell .rail{transition:margin-left .22s ease,width .22s ease,transform .22s ease}
#menu-toggle{display:grid!important;place-items:center;flex:none;width:38px;height:38px;border:1px solid var(--border);border-radius:8px;background:transparent;color:var(--text);padding:0;transition:background .2s}
#menu-toggle:hover,.v40-theme-toggle:hover{background:var(--card2)}
.v40-theme-toggle{display:inline-flex;align-items:center;gap:5px;justify-content:center;min-width:76px;height:36px;padding:0 11px;border:1px solid var(--border);border-radius:8px;background:transparent;color:var(--text);font-size:12px;font-weight:700;white-space:nowrap}
.shell.v40-rail-collapsed .rail{transform:translateX(-105%);pointer-events:none}
.shell.v40-rail-collapsed .work-area{margin-left:0;width:100%}
.shell.v40-rail-collapsed .page{max-width:100%;padding-inline:clamp(20px,3.25vw,62px)}
.shell.v40-rail-collapsed .footer{padding-inline:clamp(20px,3.25vw,62px)}
.header-avatar{overflow:hidden;cursor:pointer;display:grid;place-items:center;padding:0;flex:none}
.v40-avatar-image{width:100%;height:100%;object-fit:cover;border-radius:50%}
.v40-enroll-actions{display:flex;flex-direction:column;align-items:flex-end;gap:8px;max-width:270px;flex:none}
.v40-enrollment-note{font-size:11px;line-height:1.5;color:var(--muted);margin:0;text-align:right;max-width:265px}
.v40-enroll{min-width:200px;min-height:42px}
.v40-onboard-form{display:grid;gap:14px}.v40-onboard-form .solid-btn{width:100%;min-height:46px}
.v40-field-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px}
.v40-hint{font-size:11px!important;line-height:1.65;color:var(--muted)!important;margin:0!important}
.v40-step{font:700 10px var(--mono);letter-spacing:1.2px;color:var(--green)!important;margin:0!important}
.v40-divider{margin:19px 0 15px;position:relative;text-align:center;color:var(--muted);font:11px var(--mono)}
.v40-divider:before{content:'';position:absolute;left:0;right:0;top:50%;height:1px;background:var(--border)}
.v40-divider span{position:relative;padding:0 13px;background:var(--card)}
.v40-google-button{min-height:44px;display:flex;align-items:center;justify-content:center}
.v40-text-button{border:0;background:transparent;color:var(--green);padding:2px 4px;font-size:12px;text-decoration:underline}
.v20-dialog select{width:100%;background:var(--card);color:var(--text);border:1px solid var(--border);border-radius:8px;padding:12px;min-height:45px;font:500 14px var(--sans)}
.v20-dialog input[type=file]{font-size:12px}
.v20-dialog input[type=file]::file-selector-button{background:var(--card2);color:var(--text);border:1px solid var(--border);padding:8px;border-radius:6px;margin-right:8px}
.v20-dialog label small{font-weight:400;color:var(--muted)}
@media(min-width:1050px){
 .shell.v40-rail-collapsed .v32-studio.v32-open .v32-layout{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
 .shell.v40-rail-collapsed .v32-studio .v32-frame-shell{min-height:395px;height:calc(100% - 100px)}
 .shell.v40-rail-collapsed .v32-studio .v32-editor{min-height:450px}
}
@media(min-width:851px){.shell:not(.v40-rail-collapsed) .v32-studio.v32-open .v32-layout{grid-template-columns:minmax(0,1fr)}}
@media(max-width:850px){.shell.v40-rail-collapsed .rail{transform:translateX(-100%)}.shell .work-area{margin-left:0!important;width:100%!important}.shell .rail.open{transform:translateX(0)}.v40-theme-toggle{min-width:64px}.header-actions .v20-top-account{display:none}.shell .page{max-width:100%}}
@media(max-width:620px){.header-avatar{display:grid!important}.v40-enroll-actions{align-items:stretch;max-width:none;width:100%;margin-top:18px}.v40-enrollment-note{text-align:left}.topbar{gap:9px}.breadcrumbs .breadcrumb-brand{display:none}.header-actions{gap:6px}.v40-theme-toggle{font-size:11px;min-width:55px;height:35px;padding:0 7px}.v40-field-grid{grid-template-columns:1fr}.v20-dialog{max-height:calc(100dvh - 18px)}}
@media(prefers-reduced-motion:reduce){.shell .work-area,.shell .rail{transition:none}}
/* Consistent dark surfaces: reserved tones rather than AI-like glows/gradients. */
html[data-theme="dark"] body{background:var(--paper);color:var(--text)}
html[data-theme="dark"] :is(.topbar,.course-stat,.progress-block,.track-card,.content-card,.course-panel,.meter-card,.progress-profile .progress-block,.modal-box,.v20-dialog,.v35-video-source,.v36-video-resource,.v28-practice-grid>div,.v30-test-row,.v32-studio,.v31-step-feedback,.v22-ladder li,.v40-divider span){background:var(--card)!important;color:var(--text);border-color:var(--border)!important}
html[data-theme="dark"] :is(.banner-strip,.lesson-status,.result,.v20-sync-box,.option.selected,.v20-conflict,.v21-q,.v12-study-tools,.v30-watch-steps li,.v16-skill-head,.v35-video-clinic){background:var(--card2)!important;color:var(--text);border-color:var(--border)!important}
html[data-theme="dark"] :is(.lead,.micro,.smallmeta,.course-stat span,.track-bottom small,.track-num,.sidebar-note p,.course-title p,.track-card p,.v20-muted,.v20-dialog p,.module-head p,.footer,.v35-video-source p,.v36-video-resource p,.v32-studio p,.v40-hint){color:var(--muted)!important}
html[data-theme="dark"] :is(.search-trigger,.search-bar,.tutor-text,.option,.v20-dialog input,.v20-dialog select,.v20-tabs button,.module-head,.modal-box input,.modal-result,.outline-btn,.v32-viewports button,.v32-result-pane,.v32-file-tabs,.v32-console-title,.v32-browser-console,.v30-test-row details,.v21-security-panel,.v20-dialog #cloud-account-close){background:var(--card2);color:var(--text);border-color:var(--border)}
html[data-theme="dark"] :is(.track-card h3,.track-mark,.course-stat strong,.progress-block strong,.module-head h3,.v20-dialog h2,.v20-dialog label,.breadcrumb-brand,.tab.active,.flat-btn,.v35-video-source h4,.v36-video-resource h4,.v31-masterclass h2,.v30-masterclass h2,.v20-sync-box strong){color:var(--text)}
html[data-theme="dark"] :is(.v20-tabs button.active,.solid-btn){background:#799c89;color:#0d1c17;border-color:#799c89}
html[data-theme="dark"] .solid-btn:hover{background:#9bbba7}
html[data-theme="dark"] .outline-btn:hover{background:#2b3d35}
html[data-theme="dark"] .search-trigger kbd{background:var(--deep2);border-color:var(--border);color:var(--muted)}
html[data-theme="dark"] .v20-overlay{background:rgba(0,5,4,.77)}
html[data-theme="dark"] .v20-dialog{box-shadow:0 30px 80px rgba(0,0,0,.45)}
html[data-theme="dark"] .v20-dialog .v20-overline{color:#b2d2be}
html[data-theme="dark"] .v20-dialog .v20-error{color:#efb4a2}
html[data-theme="dark"] :is(.v20-dialog input::placeholder,.search-bar::placeholder,.tutor-text::placeholder){color:#8ca59a}
html[data-theme="dark"] :is(.module,.module-head,.lesson-row,.lesson-nav,.v20-dialog-head,.track-bottom,.status-line,.v20-tabs,.tabs,.v31-masterclass,.v32-file-tabs){border-color:var(--border)!important}
html[data-theme="dark"] .module-head:hover,html[data-theme="dark"] .lesson-row:hover,html[data-theme="dark"] .modal-result:hover{background:#23332c}
html[data-theme="dark"] .lesson-row{color:var(--text)}
html[data-theme="dark"] .option.good{background:#243e32;border-color:#678f79}html[data-theme="dark"] .option.bad{background:#462c2a;border-color:#995e5b}
html[data-theme="dark"] .v32-code-pane{background:#0b1414;border-color:#354842}html[data-theme="dark"] .v32-editor{background:#101b1b;color:#dcf0e5}
html[data-theme="dark"] .v32-browser-console{background:#16251e;color:#d0e5d7}
html[data-theme="dark"] .v32-result-pane{background:#f5f7f5;color:#29302c}html[data-theme="dark"] .v32-result-pane .v32-pane-head{background:#e9ede8;color:#23332a}
html[data-theme="dark"] :is(.tutor-answer,.tutor-bubble,.ai-study-guide){background:var(--card2);color:var(--text);border-color:var(--border)}
html[data-theme="dark"] .dashboard-hero{background:#1c2c28;border:1px solid var(--border)}
html[data-theme="dark"] .v20-dialog .v40-divider span{background:var(--card)}
html[data-theme="dark"] .v32-studio .v32-pane-head:not(.v32-code-pane .v32-pane-head){border-color:#ccd8cf}
/* Original lesson case studies and sourced topic video exercises. */
.v40-study-card,.v40-video-card{background:var(--card);border:1px solid var(--border);border-radius:12px;margin-top:24px;padding:clamp(20px,3vw,32px);box-shadow:var(--v40-shadow)}
.v40-study-card h3,.v40-video-card h3{font-size:clamp(18px,2vw,25px);line-height:1.25;margin:8px 0 22px;letter-spacing:-.4px;color:var(--text)}
.v40-study-label{font:700 10px var(--mono);color:var(--green);letter-spacing:1.2px}
.v40-study-section{margin-top:17px;padding-top:17px;border-top:1px solid var(--border)}
.v40-study-section h4{font-size:13px;margin:0 0 8px;color:var(--text)}
.v40-study-section p,.v40-video-card p{font-size:13px;line-height:1.85;color:var(--muted);white-space:pre-wrap;overflow-wrap:anywhere}
.v40-study-code{background:#172321;color:#e2efe8;border-radius:9px;padding:16px;overflow:auto;font:12px/1.65 var(--mono);white-space:pre;max-width:100%}
.v40-video-caveat{font-size:11px!important;color:var(--muted);border-top:1px solid var(--border);padding-top:11px}
.v40-video-card .outline-btn{display:inline-block;padding:9px 13px;text-decoration:none}
html[data-theme="dark"] :is(.v40-study-card,.v40-video-card){background:var(--card);border-color:var(--border)}

/* Tensora editorial refinement — restrained neutrals and consistent legibility. */
html[data-theme="light"]{color-scheme:light;--paper:#f3f2ee;--card:#fffefa;--card2:#f3f5f1;--border:#d7dfd8;--text:#243632;--muted:#64746c;--green:#355d50;--greenlight:#e5ede7;--deep:#1e2b2b;--deep2:#263938;--copper:#ae8268;--v40-shadow:0 9px 24px rgba(23,39,33,.045)}
html[data-theme="dark"]{color-scheme:dark;--paper:#101716;--card:#1a2421;--card2:#22302a;--border:#35443e;--text:#edf1ec;--muted:#b0bfb5;--green:#b3d6bc;--greenlight:#2b4438;--deep:#0f1918;--deep2:#192724;--copper:#d4a48d;--navtext:#bbccc2;--v40-shadow:0 12px 34px rgba(0,0,0,.16)}
/* Keep navigation access visible while scrolling, without covering the content. */
.shell .topbar{position:sticky;top:0;z-index:28;background:var(--card);border-bottom:1px solid var(--border);backdrop-filter:none;box-shadow:0 2px 11px rgba(16,33,25,.035)}
#menu-toggle{position:relative;z-index:2;background:var(--card);border-color:var(--border);color:var(--text);min-width:42px;min-height:42px;border-radius:10px}
#menu-toggle:hover,#menu-toggle:focus-visible{background:var(--card2);border-color:var(--green)}
.v40-theme-toggle{min-height:40px;border-color:var(--border);font-weight:600;letter-spacing:.01em;border-radius:10px;padding:0 14px}
.v20-dialog{background:var(--card);border:1px solid var(--border);box-shadow:0 26px 72px rgba(16,30,23,.19);border-radius:16px}
.v20-dialog-head{border-color:var(--border)}
.v20-dialog h2{font-size:clamp(21px,3vw,26px);letter-spacing:-.035em;color:var(--text)}
.v20-dialog .v20-overline{font:700 10px var(--sans);letter-spacing:.16em;color:var(--green)}
.v20-dialog .v20-muted{color:var(--muted);font-size:12px!important;line-height:1.7}
.v20-dialog label{color:var(--text)}
.v20-dialog input,.v20-dialog select{background:var(--card);color:var(--text);border:1px solid var(--border);border-radius:9px;min-height:45px}
.v20-dialog input:focus-visible,.v20-dialog select:focus-visible{border-color:var(--green)}
.v20-dialog .solid-btn{background:#315c4c;color:#fff;border-color:#315c4c;border-radius:8px;min-height:44px}
.v20-dialog .outline-btn{background:transparent;border:1px solid var(--border);color:var(--text);border-radius:8px;min-height:44px}
.v20-dialog .outline-btn:hover{background:var(--card2)}
.v20-tabs{gap:6px}
.v20-tabs button{border-radius:8px}
.v42-guest-actions{margin-top:19px!important;border-top:1px solid var(--border);padding-top:15px}
.v42-guest-actions .outline-btn{width:100%;background:transparent}
html[data-theme="dark"] .v20-dialog{background:var(--card)!important;color:var(--text);border-color:var(--border)}
html[data-theme="dark"] .v20-dialog .solid-btn{background:#adcdb7!important;color:#15241d!important;border-color:#adcdb7!important}
html[data-theme="dark"] .v20-dialog :is(input,select){background:#202d27;color:#edf1ec;border-color:#42574a}
html[data-theme="dark"] .v20-dialog .outline-btn{background:#202d27;color:#edf1ec;border-color:#42574a}
html[data-theme="dark"] .shell .topbar{background:#1a2421}
html[data-theme="dark"] #menu-toggle{background:#1a2421;color:#edf1ec}
html[data-theme="dark"] #menu-toggle:hover{background:#293a31}
html[data-theme="dark"] .v40-theme-toggle{background:#202d27;color:#edf1ec}
html[data-theme="dark"] .rail{background:#0f1918;border-color:#33443c}
html[data-theme="dark"] .rail .side-link.active{background:#2b4338;color:#f3f6f1;border-color:#466252}
@media(max-width:620px){.shell .topbar{z-index:28}.v40-theme-toggle{min-width:70px;padding:0 9px}#menu-toggle{min-height:40px;min-width:40px}}

/* Edition 2026: distinct editorial light + studio dark palettes.
   Surface tokens are intentionally different between modes, not simple inversions. */
html[data-theme="light"]{
  color-scheme:light;
  --paper:#f5f3ee;--card:#ffffff;--card2:#edf2f0;
  --border:#ced8d5;--line:#d6ddd8;--text:#172e32;--ink:#172e32;
  --muted:#526a70;--green:#176c66;--greenlight:#e0eeea;
  --deep:#172c32;--deep2:#234047;--copper:#9d7354;
  --navtext:#d1dfdc;--surface:#ffffff;--panel:#ffffff;
  --bg-soft:#eaf0ed;--text-muted:#526a70;--accent:#176c66;
  --v40-shadow:0 8px 25px rgba(28,48,53,.065);
}
html[data-theme="dark"]{
  color-scheme:dark;
  --paper:#111923;--card:#1b2732;--card2:#23323e;
  --border:#354753;--line:#354753;--text:#e9edf0;--ink:#e9edf0;
  --muted:#b2c0c7;--green:#94d0c2;--greenlight:#1e413f;
  --deep:#0d151d;--deep2:#16232e;--copper:#d9ae8b;
  --navtext:#b2c4cb;--surface:#1b2732;--panel:#1b2732;
  --bg-soft:#253743;--text-muted:#a9bac4;--accent:#94d0c2;
  --v40-shadow:0 14px 38px rgba(0,0,0,.25);
}
html[data-theme="light"] body{background:var(--paper);color:var(--text)}
html[data-theme="dark"] body{background:var(--paper)!important;color:var(--text)}
html[data-theme="light"] :is(.topbar,.track-card,.content-card,.course-panel,.course-stat,.progress-block,.meter-card,.modal-box,.v20-dialog,.v32-studio,.v40-study-card,.v40-video-card){background:var(--card);border-color:var(--border);color:var(--text)}
html[data-theme="dark"] :is(.topbar,.track-card,.content-card,.course-panel,.course-stat,.progress-block,.meter-card,.modal-box,.v20-dialog,.v32-studio,.v40-study-card,.v40-video-card){background:var(--card)!important;border-color:var(--border)!important;color:var(--text)}
html[data-theme="light"] .rail{background:#172c32;color:#d1dfdc;border-color:#30494c}
html[data-theme="dark"] .rail{background:#0d151d!important;color:#b2c4cb;border-color:#273d47!important}
html[data-theme="light"] .rail .side-link.active{background:#29494c;color:#fff;border-color:#436469}
html[data-theme="dark"] .rail .side-link.active{background:#24413f!important;color:#d8f1e8!important;border-color:#37645f!important}
html[data-theme="dark"] .shell .topbar{background:#1b2732!important}
html[data-theme="dark"] #menu-toggle{background:#253744!important;color:#e9edf0;border-color:#40545d}
html[data-theme="dark"] #menu-toggle:hover{background:#344b58!important}
html[data-theme="dark"] .v40-theme-toggle{background:#253744!important;color:#e9edf0;border-color:#40545d}
html[data-theme="light"] .v40-theme-toggle,html[data-theme="light"] #menu-toggle{background:#fff;color:#19363a;border-color:#c7d5d2}
html[data-theme="dark"] .v20-dialog :is(input,select,textarea){background:#14212b!important;color:#edf3f5!important;border-color:#49606d!important}
html[data-theme="light"] .v20-dialog :is(input,select,textarea){background:#fff;color:#172e32;border-color:#bacfca}
html[data-theme="dark"] .v20-dialog .outline-btn{background:#263845;color:#e8f0f1;border-color:#4c6270}
html[data-theme="dark"] .v20-dialog .solid-btn{background:#96cbbd!important;color:#122c2c!important;border-color:#96cbbd!important}
html[data-theme="light"] .v20-dialog .solid-btn{background:#176c66!important;color:white!important;border-color:#176c66!important}
html[data-theme="dark"] :is(.search-trigger,.search-bar,.tutor-text,.option,.v20-tabs button,.module-head,.outline-btn){background:#23323e!important;color:#e9edf0;border-color:#354753}
html[data-theme="dark"] :is(.banner-strip,.lesson-status,.v20-sync-box,.option.selected,.v21-q,.v12-study-tools){background:#23323e!important;color:#e9edf0;border-color:#354753}
html[data-theme="light"] :is(.search-trigger,.search-bar,.tutor-text,.option,.v20-tabs button,.module-head,.outline-btn){background:#f2f6f4;color:#172e32;border-color:#ced8d5}
html[data-theme="light"] :is(.banner-strip,.lesson-status,.v20-sync-box,.option.selected,.v21-q,.v12-study-tools){background:#edf2f0;color:#172e32;border-color:#ced8d5}
html[data-theme="dark"] .dashboard-hero{background:#203540!important;border-color:#3c5260!important}
/* Light-mode hero: keep its editorial dark panel so light text remains legible.
   Explicitly scope typography and diagram colors to avoid token overrides. */
html[data-theme="light"] .dashboard-hero{
  background:#193a3d!important;
  border:1px solid #284b4d!important;
  color:#f7f8f3!important;
  box-shadow:0 14px 34px rgba(17,49,51,.12);
}
html[data-theme="light"] .dashboard-hero h1{color:#ffffff!important}
html[data-theme="light"] .dashboard-hero h1 em{color:#b9d9c7!important}
html[data-theme="light"] .dashboard-hero p{color:#d5e4dd!important}
html[data-theme="light"] .dashboard-hero .kicker{color:#f0bd95!important}
html[data-theme="light"] .dashboard-hero .hero-diagram{border-color:#80a69b}
html[data-theme="light"] .dashboard-hero .hero-diagram:before{border-color:#73998d}
html[data-theme="light"] .dashboard-hero .hero-diagram:after{border-color:#dbab86}
html[data-theme="light"] .dashboard-hero .hero-diagram strong{color:#d7e8df}
html[data-theme="light"] .dashboard-hero .light-btn{
  background:#f8f7f0!important;color:#17383b!important;
  border-color:#f8f7f0!important;
}
html[data-theme="light"] .dashboard-hero .light-btn:hover{background:#e5eee7!important;border-color:#e5eee7!important}
html[data-theme="light"] .dashboard-hero .light-btn:focus-visible{outline:3px solid #f0bd95;outline-offset:3px}
html[data-theme="dark"] .v32-code-pane{background:#0d151d;border-color:#364958}
html[data-theme="dark"] .v32-editor{background:#111e29;color:#dfebf1}
html[data-theme="light"] .v32-editor{background:#f8faf9;color:#1c333c}
html[data-theme="dark"] .v32-browser-console{background:#172530;color:#d2e7e4}
html[data-theme="dark"] .v32-result-pane{background:#f8faf9;color:#1d2a2b}
html[data-theme="dark"] :is(.lesson-row,.module-head,.track-card,.content-card,.course-panel){border-color:var(--border)!important}
html[data-theme="dark"] :is(.lesson-row:hover,.module-head:hover){background:#263844!important}
html[data-theme="light"] :is(.lesson-row:hover,.module-head:hover){background:#e8f1ee}
html[data-theme="dark"] :is(a,button,input,select):focus-visible{outline:2px solid #c3dcd1;outline-offset:2px}
html[data-theme="light"] :is(a,button,input,select):focus-visible{outline:2px solid #176c66;outline-offset:2px}
@media(prefers-reduced-motion:reduce){html :is(button,a){transition:none!important}}


/* V45: coherent contrast for course modules across BOTH themes.
   Earlier palette overrides tinted the module header but left lesson rows light
   with inherited pale text in dark mode. Explicit component tokens fix this. */
html[data-theme="light"] {
  --course-module-bg:#ffffff;
  --course-module-text:#172e32;
  --course-module-muted:#526a70;
  --course-module-row:#f5f7f6;
  --course-module-hover:#e8f1ee;
  --course-module-border:#ced8d5;
}
html[data-theme="dark"] {
  --course-module-bg:#1b2732;
  --course-module-text:#edf3f5;
  --course-module-muted:#b7c8d0;
  --course-module-row:#23323e;
  --course-module-hover:#2b4350;
  --course-module-border:#40545f;
}
html[data-theme] .course-panel .module {border-color:var(--course-module-border)!important}
html[data-theme] .course-panel .module-head {
  background:var(--course-module-bg)!important;
  color:var(--course-module-text)!important;
  border:1px solid var(--course-module-border)!important;
  border-radius:9px;padding:16px 18px;margin:12px 0 8px;
  min-height:82px;
}
html[data-theme] .course-panel .module-head:is(:hover,:focus-visible) {
  background:var(--course-module-hover)!important;
}
html[data-theme] .course-panel .module-head :is(h3,.micro) {color:var(--course-module-text)!important}
html[data-theme] .course-panel .module-head :is(p,.module-right) {color:var(--course-module-muted)!important}
html[data-theme] .course-panel .lesson-row {
  background:var(--course-module-row)!important;
  color:var(--course-module-text)!important;
  border:1px solid var(--course-module-border)!important;
  border-radius:8px;padding:13px 15px;min-height:48px;
}
html[data-theme] .course-panel .lesson-row:is(:hover,:focus-visible) {
  background:var(--course-module-hover)!important;
  border-color:var(--green)!important;
}
html[data-theme] .course-panel .lesson-row strong {color:var(--course-module-text)!important}
html[data-theme] .course-panel .lesson-row :is(.n,.right) {color:var(--course-module-muted)!important}
html[data-theme] .course-panel .lesson-row.passed {border-left:3px solid var(--green)!important}
html[data-theme] .course-panel .lesson-row.passed .n {color:var(--green)!important}
html[data-theme="dark"] .course-panel .share-tag {
  background:#3b3630!important;color:#f1ceb0!important;
}
html[data-theme="light"] .course-panel .share-tag {
  background:#ede6db!important;color:#735338!important;
}
/* Navbar scrolls with the document. ONLY the sidebar button remains fixed. */
.shell .topbar {position:relative!important;top:auto!important;z-index:26;box-shadow:none}
.shell .topbar::before {content:"";width:42px;min-width:42px;flex:none}
.shell .topbar #menu-toggle {
  position:fixed!important;top:16px;left:calc(258px + clamp(20px,4.3vw,65px));
  z-index:75!important;width:42px;height:42px;
  box-shadow:0 5px 18px rgba(12,30,33,.17);
}
.shell.v40-rail-collapsed .topbar #menu-toggle {left:clamp(20px,4.3vw,65px)}
@media(max-width:850px){
  .shell .topbar #menu-toggle,.shell.v40-rail-collapsed .topbar #menu-toggle {top:12px;left:17px}
}
@media(max-width:620px){
  .shell .topbar #menu-toggle,.shell.v40-rail-collapsed .topbar #menu-toggle {top:12px;left:17px}
}

/* Cross-component visual contrast audit: question, test, notes, panels, inputs. */
html[data-theme="dark"] :is(.question,.check-line,.v30-test-row,.v28-practice-grid>div,.lesson-nav,.course-stat,.meter-card,.pill,.v35-video-clinic,.v40-study-card,.v40-video-card){background:var(--card)!important;color:var(--text)!important;border-color:var(--border)!important}
html[data-theme="dark"] :is(.question h3,.question strong,.course-stat strong,.check-line strong,.lesson-nav strong,.v30-test-row strong){color:var(--text)!important}
html[data-theme="dark"] :is(.question p,.meter-card small,.lesson-nav small,.course-stat span){color:var(--muted)!important}
html[data-theme="dark"] .option:not(.good):not(.bad){background:var(--card2)!important;color:var(--text)!important;border-color:var(--border)!important}
html[data-theme="dark"] .option b{color:var(--muted)!important}
html[data-theme="dark"] :is(.search-bar,.tutor-text,.modal-box input,.v20-dialog input){background:#14212b!important;color:var(--text)!important;border-color:#49606d!important}
html[data-theme="light"] :is(.question,.check-line,.v30-test-row,.v28-practice-grid>div,.lesson-nav,.course-stat,.meter-card,.pill){background:var(--card)!important;color:var(--text)!important;border-color:var(--border)!important}
html[data-theme="light"] :is(.question h3,.question strong,.course-stat strong,.check-line strong,.lesson-nav strong){color:var(--text)!important}
html[data-theme="light"] .option:not(.good):not(.bad){background:#f5f7f6!important;color:var(--text)!important;border-color:var(--border)!important}
html[data-theme="light"] :is(.search-bar,.tutor-text,.modal-box input,.v20-dialog input){background:#fff!important;color:var(--text)!important;border-color:var(--border)!important}
html[data-theme] :is(.lesson-row,.module-head,.option,.tab,.side-link):focus-visible{outline:3px solid var(--green)!important;outline-offset:2px}


/* V46: Component-level semantic colors. Avoid hard-coded pale panels in dark mode. */
html[data-theme="light"] {
  --course-feature-bg:#e6ece7;
  --course-feature-border:#bfcfc5;
  --course-feature-heading:#203c35;
  --course-feature-body:#485f58;
  --course-feature-action:#243744;
  --course-feature-action-text:#f5f8f8;
}
html[data-theme="dark"] {
  --course-feature-bg:#1b2b35;
  --course-feature-border:#435863;
  --course-feature-heading:#eff5f5;
  --course-feature-body:#bbced3;
  --course-feature-action:#91bcae;
  --course-feature-action-text:#102624;
}
html[data-theme] .course-project-link {
  background:var(--course-feature-bg)!important;
  border:1px solid var(--course-feature-border)!important;
  color:var(--course-feature-heading)!important;
}
html[data-theme] .course-project-link b {color:var(--course-feature-heading)!important}
html[data-theme] .course-project-link p {color:var(--course-feature-body)!important;line-height:1.65}
html[data-theme] .course-project-link .outline-btn {
  background:var(--course-feature-action)!important;
  border-color:var(--course-feature-action)!important;
  color:var(--course-feature-action-text)!important;
  min-height:42px;
}
html[data-theme] .course-project-link .outline-btn:hover {filter:brightness(1.10)}
/* Other legacy pale callouts must inherit the active theme, not the old palette. */
html[data-theme="dark"] :is(.insight-box,.ai-review-section,.ai-provider-status,.chapter-steps,.chapter-step,.project-card,.result,.result.fail,.v20-conflict) {
  background:var(--card2)!important;border-color:var(--border)!important;color:var(--text)!important;
}
html[data-theme="dark"] :is(.insight-box p,.ai-review-section p,.chapter-intro,.chapter-step p,.project-card p,.result p) {color:var(--muted)!important}
html[data-theme="dark"] :is(.insight-box b,.chapter-step strong,.project-card h3,.result strong) {color:var(--text)!important}
html[data-theme="dark"] :is(.modal-result small,.modal-result strong) {color:var(--muted)!important}
html[data-theme="dark"] .result.fail {border-left:3px solid #d79c84!important}
html[data-theme="dark"] :is(.option.good,.option.bad) {color:var(--text)!important}
html[data-theme="dark"] .option.good {background:#1e4436!important;border-color:#5e9979!important}
html[data-theme="dark"] .option.bad {background:#4a302d!important;border-color:#bd7770!important}

/* V46: Sidebar control is part of the rail while expanded, not outside its edge.
   On collapse (and closed mobile drawer), the SAME button returns to the header.
   The header remains in normal document flow; no sticky upper navigation bar. */
.shell .rail {position:fixed}
.shell .rail #menu-toggle {
  position:absolute!important;top:27px;right:15px;left:auto!important;
  z-index:2!important;width:38px;height:38px;
  border:1px solid #4d666b!important;background:#263b43!important;
  color:#f1f6f6!important;box-shadow:none;
}
.shell .rail #menu-toggle:hover {background:#35505a!important}
.shell .rail .wordmark {padding-right:46px}
.shell .topbar #menu-toggle,
.shell.v40-rail-collapsed .topbar #menu-toggle {
  position:relative!important;top:auto!important;left:auto!important;
  right:auto!important;flex:none;z-index:2!important;
  width:42px;height:42px;box-shadow:none;
}
.shell .topbar::before {content:none!important;display:none!important}
.shell .topbar {position:relative!important;top:auto!important}
@media(max-width:850px) {
  .shell .rail #menu-toggle {top:26px;right:14px}
  .shell .topbar #menu-toggle {top:auto!important;left:auto!important}
}
@media(max-width:620px) {
  .shell .topbar #menu-toggle {top:auto!important;left:auto!important}
}

/* V47: Keep the reopen control fixed in the viewport while the sidebar is
   collapsed. Only this control sticks; the full topbar scrolls normally.
   Expanded mode still places the same button inside the fixed sidebar. */
.shell:not(.tensora-toggle-in-rail) .topbar #menu-toggle {
  position:fixed!important;
  top:max(14px, env(safe-area-inset-top))!important;
  left:max(16px, env(safe-area-inset-left))!important;
  right:auto!important;
  bottom:auto!important;
  z-index:75!important;
  width:42px;height:42px;
  box-shadow:0 5px 18px rgba(12,30,33,.20)!important;
}
/* Reserve the button's former space so the scrolling header does not
   overlap its breadcrumbs or other controls at the top of the page. */
.shell:not(.tensora-toggle-in-rail) .topbar::before {
  content:""!important;display:block!important;
  width:42px;min-width:42px;flex:none;
}
@media (max-width:620px) {
  .shell:not(.tensora-toggle-in-rail) .topbar #menu-toggle {
    top:max(12px, env(safe-area-inset-top))!important;
    left:max(12px, env(safe-area-inset-left))!important;
  }
}
