/*
 * cs_tutorial.css —— 计算机教程自学（/tools/cs-tutorial）
 * 1) 主题变量定义在 :root（浅色主题挂 [data-theme="light"]）
 * 2) 所有 [hidden] 元素有兜底
 * 3) 断点体系（降级）：≥1400 / ≥1200 / ≥980 / ≥767 / ≥480
 * 4) 性能：卡片与长列表使用 content-visibility，减少首屏布局与绘制开销
 */

:root {
    --cs-bg: #0f1216;
    --cs-bg-2: #141a20;
    --cs-card: #171e25;
    --cs-card-2: #1d252e;
    --cs-border: #26313b;
    --cs-border-2: #35434f;
    --cs-text: #e6ecf2;
    --cs-sub: #a3b1bf;
    --cs-faint: #7b8a99;
    --cs-accent: #2fbf71;
    --cs-accent-2: #26a35e;
    --cs-accent-soft: rgba(47, 191, 113, .14);
    --cs-blue: #58a6ff;
    --cs-warn: #d8a327;
    --cs-err: #f0645a;
    --cs-code-bg: #0c1014;
    --cs-shadow: 0 18px 44px -26px rgba(0, 0, 0, .9);
    --cs-r: 14px;
    --cs-r-s: 9px;
}

[data-theme="light"] {
    --cs-bg: #f4f7f9;
    --cs-bg-2: #ffffff;
    --cs-card: #ffffff;
    --cs-card-2: #f2f6f8;
    --cs-border: #e2e8ee;
    --cs-border-2: #cfd8e0;
    --cs-text: #16212b;
    --cs-sub: #4b5b6b;
    --cs-faint: #6b7a8a;
    --cs-accent: #1f9d5c;
    --cs-accent-2: #17834b;
    --cs-accent-soft: rgba(31, 157, 92, .10);
    --cs-blue: #0a66c2;
    --cs-warn: #9a6b00;
    --cs-err: #c0392b;
    --cs-code-bg: #f6f8fa;
    --cs-shadow: 0 12px 30px -22px rgba(22, 33, 43, .45);
}

/* 满屏（保留左侧站点导航壳） */
body.page-cs-tutorial-full .app,
body.page-cs-tutorial-full .main-content,
body.page-cs-tutorial-full .page-container {
    max-width: 100%;
}

body.page-cs-tutorial-full .main-content {
    width: 100%;
    border-right: 0;
}

/* 站点 body{overflow-y:scroll} 会让 body 成为滚动容器，页面内 sticky 全部失效 */
body.page-cs-tutorial-full {
    overflow: visible;
}

/* 抽屉 / 侧栏打开时锁定背景滚动 */
body.cs-drawer-open,
body.cs-side-open {
    overflow: hidden;
}

.cs {
    padding: 20px 24px 72px;
    color: var(--cs-text);
}

.cs [hidden] {
    display: none !important;
}

/* ---------------- Hero ---------------- */

.cs-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    padding: 22px 24px;
    margin-bottom: 18px;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-r);
    background:
        radial-gradient(900px 260px at 8% -30%, var(--cs-accent-soft), transparent 70%),
        var(--cs-card);
    box-shadow: var(--cs-shadow);
}

.cs-hero-l { min-width: 0; }

.cs-hero h1 {
    margin: 0 0 6px;
    font-size: 24px;
    line-height: 1.3;
    letter-spacing: .2px;
}

.cs-hero p {
    margin: 0;
    color: var(--cs-sub);
    font-size: 13.5px;
    line-height: 1.7;
}

.cs-hero-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.cs-hero-tags span {
    padding: 3px 10px;
    border: 1px solid var(--cs-border-2);
    border-radius: 999px;
    background: var(--cs-card-2);
    color: var(--cs-sub);
    font-size: 12px;
}

.cs-search {
    position: relative;
    width: 300px;
    max-width: 100%;
}

.cs-search input {
    width: 100%;
    height: 40px;
    padding: 0 34px 0 34px;
    border: 1px solid var(--cs-border-2);
    border-radius: 10px;
    background: var(--cs-bg-2);
    color: var(--cs-text);
    font-size: 14px;
    outline: none;
}

.cs-search input:focus {
    border-color: var(--cs-accent);
    box-shadow: 0 0 0 3px var(--cs-accent-soft);
}

.cs-search-ic {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cs-faint);
    font-size: 14px;
    pointer-events: none;
}

.cs-search-kbd {
    position: absolute;
    right: 9px;
    top: 50%;
    transform: translateY(-50%);
    padding: 1px 6px;
    border: 1px solid var(--cs-border-2);
    border-radius: 5px;
    color: var(--cs-faint);
    font-size: 11px;
    pointer-events: none;
}

/* ---------------- 统计 ---------------- */

.cs-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.cs-stat {
    padding: 12px 14px;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-r-s);
    background: var(--cs-card);
}

.cs-stat b {
    display: block;
    font-size: 20px;
    line-height: 1.3;
}

.cs-stat span {
    color: var(--cs-faint);
    font-size: 12px;
}

.cs-stat-bar {
    height: 4px;
    margin-top: 8px;
    border-radius: 999px;
    background: var(--cs-card-2);
    overflow: hidden;
}

.cs-stat-bar i {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--cs-accent);
}

/* ---------------- 布局 ---------------- */

.cs-layout {
    display: grid;
    grid-template-columns: 288px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.cs-side {
    position: sticky;
    top: 16px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-r);
    background: var(--cs-card);
    scrollbar-width: thin;
}

.cs-main { min-width: 0; }

/* ---------------- 侧边树 ---------------- */

.cs-tree-cat + .cs-tree-cat { margin-top: 6px; }

.cs-tree-h {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 7px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--cs-text);
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}

.cs-tree-h:hover { background: var(--cs-card-2); }
.cs-tree-ic { font-size: 14px; }
.cs-tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-tree-n { color: var(--cs-faint); font-size: 11.5px; }
.cs-tree-arrow { color: var(--cs-faint); font-size: 10px; transition: transform .18s ease; }

.cs-tree-cat.is-fold > .cs-tree-h .cs-tree-arrow,
.cs-tree-course.is-fold > .cs-tree-h .cs-tree-arrow { transform: rotate(-90deg); }

.cs-tree-cat.is-fold > .cs-tree-list,
.cs-tree-course.is-fold > .cs-tree-lessons { display: none; }

.cs-tree-list { padding: 2px 0 6px 6px; }

.cs-tree-h2 {
    color: var(--cs-sub);
    font-size: 13px;
}

.cs-tree-lessons {
    margin: 0 0 4px;
    padding: 0 0 0 10px;
    list-style: none;
    border-left: 1px solid var(--cs-border);
    /* 章节较多时跳过屏幕外布局，显著降低首屏渲染成本 */
    content-visibility: auto;
    contain-intrinsic-size: auto 320px;
}

.cs-tree-l {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 5px 7px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--cs-sub);
    font-size: 12.5px;
    text-align: left;
    cursor: pointer;
}

.cs-tree-l:hover { background: var(--cs-card-2); color: var(--cs-text); }
.cs-tree-l.is-cur { background: var(--cs-accent-soft); color: var(--cs-accent); font-weight: 600; }
.cs-tree-lt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cs-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    border: 1px solid var(--cs-border-2);
}

.cs-tree-l.is-done .cs-dot { background: var(--cs-accent); border-color: var(--cs-accent); }
.cs-tree-l.is-fav .cs-dot { background: var(--cs-warn); border-color: var(--cs-warn); }

/* ---------------- 分类与课程 ---------------- */

.cs-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.cs-chip {
    padding: 5px 12px;
    border: 1px solid var(--cs-border-2);
    border-radius: 999px;
    background: var(--cs-card);
    color: var(--cs-sub);
    font-size: 12.5px;
    cursor: pointer;
}

.cs-chip:hover { border-color: var(--cs-accent); color: var(--cs-text); }
.cs-chip.is-on { background: var(--cs-accent-soft); border-color: var(--cs-accent); color: var(--cs-accent); font-weight: 600; }
.cs-chip i { font-style: normal; color: var(--cs-faint); font-size: 11.5px; }

.cs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
    gap: 14px;
}

.cs-card {
    display: flex;
    flex-direction: column;
    padding: 16px;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-r);
    background: var(--cs-card);
    transition: transform .18s ease, border-color .18s ease;
    /* 卡片较多时跳过屏幕外布局与绘制 */
    content-visibility: auto;
    contain-intrinsic-size: auto 268px;
}

.cs-card:hover { transform: translateY(-2px); border-color: var(--cs-accent); }

.cs-card-top { display: flex; align-items: center; gap: 10px; }

.cs-card-ic {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 11px;
    background: var(--cs-accent-soft);
    color: var(--cs-accent);
    font-size: 17px;
    font-weight: 700;
}

.cs-card-tt { min-width: 0; }
.cs-card-tt h3 { margin: 0; font-size: 15.5px; line-height: 1.4; }

.cs-card-lv {
    display: inline-block;
    margin-top: 3px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    background: var(--cs-card-2);
    color: var(--cs-faint);
}

/* 难度徽标用 ASCII 类名，避免中文类名在不同编码环境下匹配失败 */
.cs-card-lv.cs-lv-1 { color: var(--cs-accent); }
.cs-card-lv.cs-lv-2 { color: var(--cs-blue); }
.cs-card-lv.cs-lv-3 { color: var(--cs-warn); }

.cs-card-desc {
    margin: 10px 0 0;
    color: var(--cs-sub);
    font-size: 12.8px;
    line-height: 1.7;
    min-height: 44px;
}

.cs-card-hits {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
}

.cs-card-hits > span { color: var(--cs-faint); font-size: 11px; }

.cs-card-hit {
    max-width: 100%;
    padding: 2px 8px;
    border: 1px solid var(--cs-border-2);
    border-radius: 6px;
    background: transparent;
    color: var(--cs-blue);
    font-size: 11px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-card-hit:hover { border-color: var(--cs-blue); }

.cs-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.cs-card-tags span {
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--cs-card-2);
    color: var(--cs-faint);
    font-size: 11px;
}

.cs-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    color: var(--cs-faint);
    font-size: 11.8px;
}

.cs-card-prog {
    height: 4px;
    margin-top: 12px;
    border-radius: 999px;
    background: var(--cs-card-2);
    overflow: hidden;
}

.cs-card-prog i { display: block; height: 100%; background: var(--cs-accent); }

.cs-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
}

.cs-card-pct { color: var(--cs-faint); font-size: 11.5px; }

.cs-btn {
    padding: 6px 14px;
    border: 1px solid var(--cs-border-2);
    border-radius: 8px;
    background: var(--cs-card-2);
    color: var(--cs-text);
    font-size: 12.5px;
    cursor: pointer;
}

.cs-btn:hover { border-color: var(--cs-accent); color: var(--cs-accent); }

.cs-btn-pri {
    border-color: transparent;
    background: var(--cs-accent);
    color: #06210f;
    font-weight: 600;
}

[data-theme="light"] .cs-btn-pri { color: #ffffff; }
.cs-btn-pri:hover { background: var(--cs-accent-2); color: #ffffff; }
.cs-btn-xs { padding: 3px 9px; font-size: 11.5px; }
.cs-btn-danger:hover { border-color: var(--cs-err); color: var(--cs-err); }
.cs-btn.is-on { border-color: var(--cs-accent); color: var(--cs-accent); background: var(--cs-accent-soft); }

/* ---------------- 章节阅读 ---------------- */

.cs-crumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    color: var(--cs-faint);
    font-size: 12.5px;
}

.cs-crumb button {
    border: 0;
    background: transparent;
    color: var(--cs-sub);
    font-size: 12.5px;
    cursor: pointer;
    padding: 0;
}

.cs-crumb button:hover { color: var(--cs-accent); }
.cs-crumb em { font-style: normal; color: var(--cs-text); }

.cs-lesson-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 18px;
    align-items: start;
}

.cs-lesson {
    padding: 22px 24px 26px;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-r);
    background: var(--cs-card);
}

.cs-lesson h1 { margin: 0 0 8px; font-size: 23px; line-height: 1.35; }
.cs-lesson-sum { margin: 0; color: var(--cs-sub); font-size: 13.5px; line-height: 1.7; }

.cs-lesson-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }

.cs-tag {
    padding: 3px 10px;
    border: 1px solid var(--cs-border-2);
    border-radius: 999px;
    background: var(--cs-card-2);
    color: var(--cs-sub);
    font-size: 11.5px;
}

.cs-lesson-ops { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; }

.cs-body { color: var(--cs-text); font-size: 14.2px; line-height: 1.9; }
.cs-body h2 { margin: 26px 0 10px; font-size: 18px; line-height: 1.5; }
.cs-body h3 { margin: 20px 0 8px; font-size: 16px; }
.cs-body h4 { margin: 16px 0 6px; font-size: 14.5px; color: var(--cs-sub); }
.cs-body h5 { margin: 14px 0 6px; font-size: 13.8px; color: var(--cs-sub); }
.cs-body p { margin: 10px 0; }
.cs-body ul, .cs-body ol { margin: 10px 0; padding-left: 22px; }
.cs-body li { margin: 5px 0; }
.cs-body strong { color: var(--cs-text); }
.cs-body code {
    padding: 1.5px 6px;
    border-radius: 5px;
    background: var(--cs-accent-soft);
    color: var(--cs-accent);
    font-size: 12.8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.cs-body a { color: var(--cs-blue); }
.cs-body a:hover { text-decoration: underline; }

.cs-note {
    margin: 12px 0;
    padding: 11px 14px;
    border-left: 3px solid var(--cs-accent);
    border-radius: 0 8px 8px 0;
    background: var(--cs-accent-soft);
    color: var(--cs-sub);
}

.cs-table-wrap { overflow-x: auto; margin: 12px 0; }

.cs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.cs-table th, .cs-table td {
    padding: 8px 11px;
    border: 1px solid var(--cs-border);
    text-align: left;
}

.cs-table th { background: var(--cs-card-2); color: var(--cs-text); font-weight: 600; }

/* ---------------- 代码块 ---------------- */

.cs-code {
    margin: 14px 0;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-r-s);
    overflow: hidden;
    background: var(--cs-code-bg);
}

.cs-code-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-bottom: 1px solid var(--cs-border);
    background: var(--cs-card-2);
}

.cs-code-lang {
    flex: 1;
    color: var(--cs-faint);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .6px;
}

.cs-code-copy, .cs-code-run {
    padding: 3px 10px;
    border: 1px solid var(--cs-border-2);
    border-radius: 6px;
    background: transparent;
    color: var(--cs-sub);
    font-size: 11.5px;
    cursor: pointer;
}

.cs-code-copy:hover, .cs-code-run:hover { border-color: var(--cs-accent); color: var(--cs-accent); }

.cs-pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    font-size: 12.8px;
    line-height: 1.75;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #d7e2ea;
    scrollbar-width: thin;
}

[data-theme="light"] .cs-pre { color: #24303a; }

.c-key { color: #ff7b9c; }
.c-str { color: #9ae6b4; }
.c-num { color: #f7c873; }
.c-com { color: #6b7f90; font-style: italic; }

.cs-code-out { border-top: 1px solid var(--cs-border); }

.cs-run-frame-wrap { padding: 0; background: #ffffff; }
.cs-run-frame { display: block; width: 100%; height: 220px; border: 0; background: #ffffff; }

.cs-run-console {
    margin: 0;
    padding: 12px 16px;
    min-height: 64px;
    max-height: 320px;
    overflow: auto;
    background: var(--cs-code-bg);
    color: #b9e6c9;
    font-size: 12.5px;
    line-height: 1.7;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap;
}

/* ---------------- 章节目录 / 翻章 ---------------- */

.cs-toc {
    position: sticky;
    top: 16px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-r);
    background: var(--cs-card);
    scrollbar-width: thin;
    content-visibility: auto;
    contain-intrinsic-size: auto 420px;
}

.cs-toc-h { margin-bottom: 8px; color: var(--cs-faint); font-size: 12px; }
.cs-toc ul { margin: 0; padding: 0; list-style: none; }

.cs-toc-l {
    display: block;
    width: 100%;
    padding: 5px 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--cs-sub);
    font-size: 12.5px;
    text-align: left;
    cursor: pointer;
}

.cs-toc-l:hover { background: var(--cs-card-2); color: var(--cs-text); }
.cs-toc-l.is-cur { background: var(--cs-accent-soft); color: var(--cs-accent); font-weight: 600; }
.cs-toc-l.is-done { color: var(--cs-accent); }

.cs-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 18px;
}

.cs-pager button {
    padding: 10px 14px;
    border: 1px solid var(--cs-border-2);
    border-radius: var(--cs-r-s);
    background: var(--cs-card-2);
    color: var(--cs-sub);
    font-size: 13px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-pager button:hover:not(:disabled) { border-color: var(--cs-accent); color: var(--cs-accent); }
.cs-pager button:disabled { opacity: .45; cursor: not-allowed; }
.cs-pager button:last-child { text-align: right; }

/* ---------------- 抽屉（笔记）与遮罩 ---------------- */

.cs-mask {
    position: fixed;
    inset: 0;
    z-index: 120000;
    display: flex;
    justify-content: flex-end;
    background: rgba(6, 10, 14, .58);
}

.cs-mask[hidden] { display: none !important; }

.cs-drawer {
    width: min(420px, 92vw);
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--cs-bg-2);
    border-left: 1px solid var(--cs-border);
    box-shadow: var(--cs-shadow);
}

.cs-drawer-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--cs-border);
}

.cs-drawer-head h3 { flex: 1; margin: 0; font-size: 15px; }

.cs-drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px; }

.cs-drawer-foot {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--cs-border);
}

.cs-note-item {
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-r-s);
    background: var(--cs-card);
}

.cs-note-head { display: flex; flex-direction: column; gap: 2px; }
.cs-note-head strong { font-size: 13px; }
.cs-note-time { color: var(--cs-faint); font-size: 11px; }
.cs-note-text { margin: 8px 0; color: var(--cs-sub); font-size: 12.8px; line-height: 1.7; white-space: pre-wrap; }
.cs-note-ops { display: flex; gap: 8px; }

.cs-note-editor {
    position: fixed;
    inset: 0;
    z-index: 121000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(6, 10, 14, .58);
}

.cs-note-editor[hidden] { display: none !important; }

.cs-note-box {
    width: min(560px, 100%);
    padding: 18px;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-r);
    background: var(--cs-bg-2);
    box-shadow: var(--cs-shadow);
}

.cs-note-box h3 { margin: 0 0 12px; font-size: 15.5px; }

.cs-note-box textarea {
    width: 100%;
    min-height: 150px;
    padding: 10px 12px;
    border: 1px solid var(--cs-border-2);
    border-radius: var(--cs-r-s);
    background: var(--cs-card);
    color: var(--cs-text);
    font-size: 13.5px;
    line-height: 1.7;
    resize: vertical;
    outline: none;
}

.cs-note-box textarea:focus { border-color: var(--cs-accent); }

.cs-note-ops2 { display: flex; gap: 8px; margin-top: 12px; }

.cs-empty {
    padding: 46px 16px;
    text-align: center;
    color: var(--cs-faint);
    border: 1px dashed var(--cs-border-2);
    border-radius: var(--cs-r);
    background: var(--cs-card);
}

.cs-empty p { margin: 0 0 12px; font-size: 13px; }
.cs-empty-ic { display: block; font-size: 26px; margin-bottom: 8px; }

.cs-loading {
    padding: 40px;
    text-align: center;
    color: var(--cs-faint);
    font-size: 13px;
}

.cs-spin {
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-right: 8px;
    border: 2px solid var(--cs-border-2);
    border-top-color: var(--cs-accent);
    border-radius: 50%;
    animation: cs-spin .8s linear infinite;
    vertical-align: -2px;
}

@keyframes cs-spin { to { transform: rotate(360deg); } }

/* 首屏骨架：数据到达前占位，避免布局跳动 */
.cs-skeleton {
    border-radius: var(--cs-r-s);
    background: linear-gradient(90deg, var(--cs-card) 25%, var(--cs-card-2) 37%, var(--cs-card) 63%);
    background-size: 400% 100%;
    animation: cs-shimmer 1.4s ease infinite;
}

.cs-skeleton-row { height: 34px; margin-bottom: 8px; }
.cs-skeleton-card { height: 168px; margin-bottom: 14px; }

@keyframes cs-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.cs-toast {
    position: fixed;
    left: 50%;
    bottom: 34px;
    z-index: 130000;
    transform: translate(-50%, 12px);
    padding: 9px 18px;
    border: 1px solid var(--cs-border-2);
    border-radius: 999px;
    background: var(--cs-bg-2);
    color: var(--cs-text);
    font-size: 13px;
    box-shadow: var(--cs-shadow);
    opacity: 0;
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
}

.cs-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.cs-side-mask {
    position: fixed;
    inset: 0;
    z-index: 110000;
    background: rgba(6, 10, 14, .55);
}

.cs-side-mask[hidden] { display: none !important; }

.cs-side-toggle { display: none; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1400px) {
    .cs-lesson-grid { grid-template-columns: minmax(0, 1fr) 220px; }
}

@media (max-width: 1200px) {
    .cs-lesson-grid { grid-template-columns: minmax(0, 1fr); }
    .cs-toc { position: static; max-height: none; content-visibility: visible; }
}

@media (max-width: 980px) {
    .cs { padding: 14px 14px 60px; }
    .cs-layout { grid-template-columns: minmax(0, 1fr); }

    .cs-side {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 110010;
        width: min(300px, 86vw);
        max-height: none;
        border-radius: 0;
        transform: translateX(-102%);
        transition: transform .22s ease;
    }

    body.cs-side-open .cs-side { transform: none; }

    .cs-side-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        height: 38px;
        padding: 0 14px;
        border: 1px solid var(--cs-border-2);
        border-radius: 9px;
        background: var(--cs-card);
        color: var(--cs-text);
        font-size: 13px;
        cursor: pointer;
    }

    .cs-hero { grid-template-columns: minmax(0, 1fr); }
    .cs-search { width: 100%; }
    .cs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
    .cs-hero { padding: 16px; }
    .cs-hero h1 { font-size: 20px; }
    .cs-lesson { padding: 16px 14px 20px; }
    .cs-lesson h1 { font-size: 19px; }
    .cs-body { font-size: 14px; }
    .cs-grid { grid-template-columns: minmax(0, 1fr); }
    .cs-pager { grid-template-columns: minmax(0, 1fr); }
    .cs-search input { font-size: 16px; }
    .cs-search-kbd { display: none; }
    .cs-note-box textarea { font-size: 16px; }
    .cs-drawer { width: 100%; }
}

@media (max-width: 480px) {
    .cs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cs-card-desc { min-height: 0; }
    .cs-code-run, .cs-code-copy { padding: 5px 9px; }
}

@media (prefers-reduced-motion: reduce) {
    .cs *, .cs-skeleton { animation: none !important; transition: none !important; }
}

@media print {
    .cs-side, .cs-toc, .cs-lesson-ops, .cs-pager, .cs-search, .cs-hero, .cs-stats { display: none !important; }
}
