html[data-theme=dark]{color-scheme:dark;--study-bg:#17191f;--study-panel:#20232b;--study-ink:#e6e8ef;--study-muted:#a0a5b2;--study-line:#343740;--study-accent:#c7cfee;--study-soft:#292d38}
html[data-theme=light]{color-scheme:light;--study-bg:#faf9f6;--study-panel:#fffefa;--study-ink:#252730;--study-muted:#666b78;--study-line:#dbdce0;--study-accent:#52649a;--study-soft:#f0f0ec}
html[data-study-shell=home][data-theme=light]{--bg:var(--study-bg);--surface:var(--study-panel);--text:var(--study-ink);--muted:var(--study-muted);--line:var(--study-line);--accent:#875565}
html[data-study-shell=home][data-theme=light] .chapter-number,html[data-study-shell=home][data-theme=light] .chapter-links,html[data-study-shell=home][data-theme=light] .page-footer,html[data-study-shell=home][data-theme=light] .resource-tag,html[data-study-shell=home][data-theme=light] .resource-type{color:var(--study-muted)}
html[data-study-shell=home][data-theme=light] .course-tabs,html[data-study-shell=home][data-theme=light] .book-simple{border-color:var(--study-line)}
html[data-study-shell=home][data-theme=light] .course-tabs button,html[data-study-shell=home][data-theme=light] .course-tabs span,html[data-study-shell=home][data-theme=light] .book-simple p,html[data-study-shell=home][data-theme=light] .textbook-tools span,html[data-study-shell=home][data-theme=light] .pdf-size,html[data-study-shell=home][data-theme=light] .resume-copy strong,html[data-study-shell=home][data-theme=light] .resume-copy span{color:var(--study-muted)}
html[data-study-shell=home][data-theme=light] .course-tabs button[aria-pressed=true]{color:var(--study-ink);border-color:var(--study-accent)}
html[data-study-shell=home][data-theme=light] dialog,html[data-study-shell=home][data-theme=light] .companion,html[data-study-shell=home][data-theme=light] .toast{background:var(--study-panel);color:var(--study-ink);border-color:var(--study-line)}
html[data-study-shell=home][data-theme=light] dialog::backdrop{background:#33374455}
html[data-study-shell=modern]{--bg:var(--study-bg);--fg:var(--study-ink);--muted:var(--study-muted);--line:var(--study-line);--panel:var(--study-panel);--accent:var(--study-accent)}
html[data-study-shell=modern] .reader-header{position:sticky;top:0;z-index:5;background:var(--study-bg)}html[data-study-shell=modern] .toc{top:92px}@media(max-width:760px){html[data-study-shell=modern] .toc{position:static}}@media print{html[data-study-shell=modern] .reader-header{position:static}}
html[data-study-shell=legacy]{--ink:var(--study-ink);--muted:var(--study-muted);--blue:var(--study-accent);--line:var(--study-line);--pale:var(--study-soft)}
html[data-study-shell=legacy] body{background:var(--study-bg);color:var(--study-ink)}
html[data-study-shell=legacy] aside{background:var(--study-bg)}
html[data-study-shell=legacy] .top{height:auto;min-height:62px;flex-wrap:wrap;gap:10px;background:var(--study-panel);color:var(--study-ink);border-bottom:1px solid var(--study-line)}
html[data-study-shell=legacy] .top a,html[data-study-shell=legacy] .top .meta{color:var(--study-muted)}
html[data-study-shell=legacy][data-theme=dark] :is(.mathblock,.formula,.equation,.pill,.cellgrid span,.cross-selected,.card,.callout,.note,.warn,.warning,.example,.lab,.stat,.controlbox,.result,.panel,th,pre,details,.nav a.active,.tools a,.path a){background:var(--study-panel);color:var(--study-ink);border-color:var(--study-line)}
html[data-study-shell=legacy][data-theme=dark] :is(button,input,select){background:var(--study-panel);color:var(--study-ink);border-color:var(--study-line)}
html[data-study-shell=legacy][data-theme=dark] svg{background:transparent}
html[data-study-shell=legacy][data-theme=dark] svg text{fill:var(--study-muted)}
html[data-study-shell=legacy][data-theme=dark] svg rect:is([fill=white],[fill="#fff"],[fill="#ffffff"]){fill:var(--study-panel)}
.study-theme-toggle,.study-ai-open{font:12px/1.5 "Microsoft YaHei",system-ui,sans-serif!important;white-space:nowrap;border:1px solid var(--study-line)!important;background:transparent!important;color:var(--study-muted)!important;border-radius:5px!important;padding:6px 10px!important;min-height:32px;cursor:pointer}
.study-theme-toggle:hover,.study-ai-open:hover{color:var(--study-ink)!important;background:var(--study-soft)!important}
.header-tools .study-theme-toggle{margin-left:7px}.header-tools .study-ai-open{margin-left:2px}
.study-legacy-controls,.study-standalone-controls{display:flex;align-items:center;gap:9px;margin-left:auto}.study-standalone-controls{max-width:1180px;margin:12px auto;padding:0 24px;justify-content:flex-end}
.study-ai-dialog{position:fixed;inset:0;width:min(660px,calc(100% - 28px));height:min(760px,calc(100dvh - 28px));max-height:calc(100dvh - 28px);max-width:calc(100% - 28px);margin:auto;padding:0;border:1px solid var(--study-line);border-radius:10px;background:var(--study-bg);color:var(--study-ink);box-shadow:0 22px 80px #0004;overflow:hidden;font:14px/1.7 "Microsoft YaHei",system-ui,sans-serif;letter-spacing:0;z-index:50}
.study-ai-dialog[open]{display:flex;flex-direction:column}.study-ai-dialog::backdrop{background:#090b1170;backdrop-filter:blur(4px)}
.study-ai-dialog *{box-sizing:border-box}.study-ai-dialog button{font:inherit;cursor:pointer;border:1px solid var(--study-line);border-radius:5px;padding:6px 11px;background:transparent;color:var(--study-ink)}
.study-ai-dialog button:hover{background:var(--study-soft)}.study-ai-dialog button:disabled{opacity:.5;cursor:default}.study-ai-dialog button:focus-visible,.study-ai-dialog input:focus-visible,.study-ai-dialog textarea:focus-visible,.study-ai-dialog select:focus-visible{outline:2px solid var(--study-accent);outline-offset:2px}
.ai-heading{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px 22px;border-bottom:1px solid var(--study-line);flex-shrink:0}.ai-heading h2{font:600 16px/1.5 "Microsoft YaHei",sans-serif;margin:0}.ai-actions{display:flex;gap:8px}.ai-actions button{font-size:12px;padding:5px 9px}.ai-status{margin:0;padding:9px 22px;color:var(--study-muted);font-size:12px;border-bottom:1px solid var(--study-line);flex-shrink:0}
.ai-config{margin:0;padding:16px 22px;border-bottom:1px solid var(--study-line);overflow:auto;flex-shrink:0;max-height:55%}.ai-config[hidden]{display:none!important}.ai-config label{display:block;color:var(--study-muted);font-size:12px;margin:0 0 12px}.ai-config :is(input,select){display:block;width:100%;min-width:0;margin-top:5px;border:1px solid var(--study-line);border-radius:5px;padding:8px 10px;background:var(--study-panel);color:var(--study-ink);font:13px/1.5 "Microsoft YaHei",sans-serif}.ai-field-row{display:grid;grid-template-columns:1fr 1.5fr;gap:14px}.ai-config-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.ai-config .ai-hint{font-size:11px;margin:12px 0 0;color:var(--study-muted)}
.ai-messages{overflow:auto;flex:1;min-height:60px;padding:20px 22px;overscroll-behavior:contain}.ai-empty{padding:24px 0;color:var(--study-muted);font-size:13px}.ai-empty h3{font-size:17px;font-weight:500;margin:0 0 9px;color:var(--study-ink)}.ai-example{display:flex;flex-wrap:wrap;gap:8px;margin-top:18px}.ai-example button{font-size:12px;text-align:left}.ai-message{margin:0 0 22px;min-width:0}.ai-message-label{font-size:11px;color:var(--study-muted);margin-bottom:7px}.ai-message-content{line-height:1.85;overflow-wrap:anywhere}.ai-message-user .ai-message-content{background:var(--study-soft);padding:11px 14px;border-radius:6px;white-space:pre-wrap}.ai-message-content p{margin:8px 0}.ai-message-content h3{font-size:15px;font-weight:600;margin:18px 0 8px;line-height:1.6}.ai-message-content pre{white-space:pre-wrap;font:12px/1.8 Consolas,monospace;border:1px solid var(--study-line);padding:12px;border-radius:5px;background:var(--study-panel);margin:14px 0;overflow:auto}.ai-message-content code{font-family:Consolas,monospace;font-size:.95em}.ai-message-content ul,.ai-message-content ol{padding-left:24px;margin:10px 0}.ai-message-content li{margin:5px 0}.ai-message-content .katex-display{max-width:100%;overflow-x:auto;overflow-y:hidden;padding:8px 0}.ai-error{color:#df8f95;font-size:12px;margin:0;padding:0 22px 10px;white-space:pre-wrap}.ai-error:empty{display:none}html[data-theme=light] .ai-error{color:#a83b4a}
.ai-compose{padding:12px 22px 17px;border-top:1px solid var(--study-line);flex-shrink:0}.ai-context{display:flex;align-items:center;gap:9px;flex-wrap:wrap;font-size:11px;color:var(--study-muted);margin-bottom:10px}.ai-context label{display:flex;align-items:center;gap:6px}.ai-context input{accent-color:var(--study-accent);width:14px;height:14px}.ai-context button{font-size:11px;padding:3px 7px}.ai-selection{max-height:62px;overflow:auto;font-size:11px;border-left:2px solid var(--study-accent);padding-left:9px;color:var(--study-muted);margin-bottom:9px;white-space:pre-wrap}.ai-compose textarea{width:100%;min-height:75px;max-height:180px;resize:vertical;padding:10px 12px;border:1px solid var(--study-line);border-radius:5px;background:var(--study-panel);color:var(--study-ink);font:13px/1.65 "Microsoft YaHei",sans-serif}.ai-send-row{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:10px}.ai-send-row span{font-size:10px;color:var(--study-muted)}.ai-send-row div{display:flex;gap:8px}.ai-send-row button{font-size:12px}.ai-send-row #ai-send{background:var(--study-soft)}
@media(max-width:720px){.header-tools{flex-wrap:wrap}.header-tools .study-theme-toggle{margin-left:3px}.study-theme-toggle,.study-ai-open{padding:5px 7px!important;font-size:11px!important}.reader-header{padding:0 18px}.reader-header>div{gap:8px}.reader-header>a{font-size:14px}.study-legacy-controls{gap:7px}.study-ai-dialog{width:calc(100% - 16px);max-width:calc(100% - 16px);height:calc(100dvh - 16px);max-height:calc(100dvh - 16px);border-radius:8px}.ai-heading{padding:13px 14px;gap:8px}.ai-heading h2{font-size:15px}.ai-actions{gap:6px}.ai-actions button{padding:4px 7px;font-size:11px}.ai-status,.ai-config,.ai-messages,.ai-compose{padding-left:14px;padding-right:14px}.ai-error{padding-left:14px;padding-right:14px}.ai-config{max-height:48%}.ai-field-row{gap:10px}.ai-send-row span{max-width:150px}.ai-example button{font-size:11px}}
