/* ============================================================
   Kozert Portal 公开内容门户样式
   暗色「热点雷达」基调 + AI Promo Now 式情报卡片
   ============================================================ */

:root {
    --bg: #0b1020;
    --bg-soft: #111832;
    --card: #141c3a;
    --card-hover: #1a2450;
    --line: rgba(148, 163, 184, .16);
    --text: #e6ebf7;
    --text-dim: #94a3b8;
    --text-faint: #64748b;
    --accent: #7c8cff;
    --accent-2: #22d3ee;
    --danger: #f472b6;
    --header-bg: rgba(11, 16, 32, .78);
    --scrim: rgba(4, 8, 20, .72);
    --radius: 14px;
    --shadow: 0 10px 30px rgba(2, 6, 23, .45);
    --header-shadow: 0 8px 28px rgba(2, 6, 23, .38);
    /* 动画节奏:入场用带一点回弹的曲线,位移只走 transform/opacity 保证 60fps */
    --ease-out: cubic-bezier(.22, .9, .32, 1);
    --ease-spring: cubic-bezier(.18, .89, .32, 1.12);
}

/* 亮色模式:同名变量整体换肤 */
body.light {
    --bg: #f4f6fb;
    --bg-soft: #ffffff;
    --card: #ffffff;
    --card-hover: #eef2fb;
    --line: rgba(15, 23, 42, .12);
    --text: #1e293b;
    --text-dim: #5b6b81;
    --text-faint: #8a99ac;
    --accent: #5566e8;
    --accent-2: #0891b2;
    --danger: #db2777;
    --header-bg: rgba(255, 255, 255, .82);
    --scrim: rgba(15, 23, 42, .45);
    --shadow: 0 10px 26px rgba(15, 23, 42, .10);
    --header-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

/* scrollbar-gutter 常驻滚动条槽位:详情弹窗锁滚动(body overflow hidden)时
   滚动条消失不再改变布局宽度,否则 .container 重新居中,整页会左右跳一下 */
html { scroll-behavior: smooth; scrollbar-gutter: stable; }

/* ---------- 滚动条:统一「悬浮胶囊」风格 ----------
   原生滚动条(尤其 Android WebView/部分国产浏览器)是贴边的直角长条:
   会盖住弹窗右缘的圆角,看起来「左边圆角右边直角」。
   自定义透明轨道 + 内缩圆角 thumb,不贴边、不压圆角。 */
* { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, .45) transparent; }
body.light { scrollbar-color: rgba(100, 116, 139, .45) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, .45);
    border: 2px solid transparent; /* 透明描边让 thumb 内缩成悬浮胶囊 */
    border-radius: 999px;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(148, 163, 184, .7); }
::-webkit-scrollbar-corner { background: transparent; }

body {
    margin: 0;
    background:
        radial-gradient(1100px 500px at 85% -10%, rgba(124, 140, 255, .16), transparent 60%),
        radial-gradient(900px 420px at 8% 8%, rgba(34, 211, 238, .10), transparent 55%),
        var(--bg);
    color: var(--text);
    font: 15px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ---------- 顶部导航 ---------- */

.site-header {
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(14px);
    background: var(--header-bg);
    border-bottom: 1px solid var(--line);
    transition: box-shadow .3s ease;
}
/* 顶栏左右留白比正文大一档:brand 图标不贴屏幕边 */
.site-header .container { padding: 0 28px; }
.site-header.scrolled { box-shadow: var(--header-shadow); }

/* 阅读进度条:贴在导航下缘,scroll 时 scaleX 拉伸 */
.scroll-progress {
    position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
    transform-origin: 0 50%; transform: scaleX(0);
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    pointer-events: none;
}

.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 62px;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
    font-size: 22px;
    width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, rgba(124, 140, 255, .25), rgba(34, 211, 238, .18));
    border: 1px solid var(--line);
    transition: transform .3s var(--ease-spring);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.08); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
/* 站名不折行:中文名没有空格,一旦被 flex 压到 min-content 会逐字换行 */
.brand-text b { font-size: 16px; letter-spacing: .3px; white-space: nowrap; }
.brand-text i { font-style: normal; font-size: 11px; color: var(--text-faint); }

/* 亮暗主题切换按钮
   color 必须显式设置:按钮是表单控件,默认色是系统黑而不是继承文字色,
   深色模式下 SVG 太阳(currentColor)会是黑色压在深色卡片上,完全看不见 */
.theme-toggle {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid var(--line); background: var(--card);
    color: var(--text);
    cursor: pointer; font-size: 16px; line-height: 1;
    display: grid; place-items: center;
    transition: border-color .2s, transform .2s var(--ease-spring);
}
.theme-toggle:hover { border-color: var(--accent); transform: scale(1.08); }
.theme-toggle.spin-once { animation: themeSpin .55s var(--ease-out); }
/* 图标用内联 SVG(emoji 月亮字形本身是歪的),固定尺寸并居中 */
.theme-toggle svg, .ld-theme svg { width: 18px; height: 18px; display: block; }

/* ---------- 顶栏登录入口(与主题切换按钮同组靠右) ----------
   未登录:「登录」胶囊;已登录:头像按钮 + 下方账号菜单(退出登录) */
.header-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.header-auth { position: relative; display: flex; align-items: center; }

.login-chip {
    height: 36px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--card);
    color: var(--text-dim); font: inherit; font-size: 13px;
    padding: 0 16px; cursor: pointer;
    transition: color .18s, border-color .18s, transform .18s var(--ease-out);
}
.login-chip:hover { color: var(--text); border-color: var(--accent); transform: translateY(-1px); }
.login-chip:active { transform: scale(.95); }

.header-avatar-btn {
    width: 36px; height: 36px; border-radius: 50%; padding: 0;
    border: 1px solid var(--line); background: transparent; cursor: pointer;
    display: grid; place-items: center;
    transition: border-color .2s, transform .2s var(--ease-spring);
}
.header-avatar-btn:hover { border-color: var(--accent); transform: scale(1.08); }
.header-avatar-btn:active { transform: scale(.96); }
.header-avatar-btn .avatar { width: 28px; height: 28px; font-size: 13px; }

.auth-menu {
    position: absolute; right: 0; top: calc(100% + 10px); z-index: 60;
    min-width: 168px; padding: 6px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--shadow);
    animation: rise .18s var(--ease-out) both;
}
.auth-menu[hidden] { display: none; }
.auth-menu-head {
    padding: 8px 10px 10px; margin-bottom: 4px;
    border-bottom: 1px dashed var(--line);
    display: flex; flex-direction: column; gap: 2px;
}
.auth-menu-head b { font-size: 13.5px; }
.auth-menu-head span { font-size: 11.5px; color: var(--text-faint); }
.auth-menu-item {
    width: 100%; text-align: left;
    border: 0; border-radius: 8px; background: transparent; cursor: pointer;
    color: var(--text-dim); font: inherit; font-size: 13px; padding: 8px 10px;
    transition: background .18s, color .18s;
}
.auth-menu-item:hover { background: rgba(148, 163, 184, .1); color: var(--danger); }
@keyframes themeSpin {
    0% { transform: rotate(0) scale(1); }
    50% { transform: rotate(180deg) scale(.78); }
    100% { transform: rotate(360deg) scale(1); }
}

/* ---------- Hero + 概览 ---------- */

.hero { padding: 72px 0 30px; text-align: center; }

/* 首屏文案逐级入场(kicker → 标题 → 副标题)。
   /study 的首屏容器是 .study-hero(不是 .hero),大标题选择器两处都要带上 */
.hero-kicker, .hero h1, .study-hero h1, .hero-sub { animation: rise .6s var(--ease-out) both; }
.hero-kicker { animation-delay: .05s; }
.hero h1, .study-hero h1 { animation-delay: .14s; }
.hero-sub { animation-delay: .24s; }

.hero-kicker {
    margin: 0 0 14px;
    font-size: 12px; letter-spacing: 3px; color: var(--accent-2);
}

.hero h1, .study-hero h1 {
    margin: 0 auto; max-width: 720px;
    font-size: clamp(30px, 5vw, 46px); line-height: 1.22; font-weight: 800;
}

.hero .accent, .study-hero .accent {
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}

.hero-sub {
    margin: 18px auto 0; max-width: 640px;
    color: var(--text-dim); font-size: 16px;
}
.hero-sub b { color: var(--text); }

.overview-grid {
    margin: 26px auto 0;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
    max-width: 640px;
}

.overview-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 10px 10px;
    box-shadow: var(--shadow);
}
.overview-card::after {
    content: ''; position: absolute; inset: 0; border-radius: inherit;
    pointer-events: none; opacity: 0;
    background: radial-gradient(180px circle at var(--mx, 50%) var(--my, 50%),
        color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%);
    transition: opacity .3s ease;
}
.overview-card.spot::after { opacity: 1; }
.overview-card b { display: block; font-size: 22px; font-weight: 800; line-height: 1.2; }
.overview-card span { font-size: 12px; color: var(--text-dim); }

/* 概览下方的热门标签云(全量标签走「查看全部标签」弹层) */
.tag-cloud {
    max-width: 880px; margin: 16px auto 0;
    display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px;
}
.tag-cloud a { font-size: 13px; color: var(--accent-2); opacity: .85; display: inline-block; transition: opacity .2s, transform .2s var(--ease-out); }
.tag-cloud a:hover { opacity: 1; transform: translateY(-2px) scale(1.08); text-decoration: none; }
/* 当前筛选中的标签在云里也高亮,再点一次即取消 */
.tag-cloud a.active { opacity: 1; font-weight: 700; color: var(--accent); text-decoration: underline; }
.tag-cloud a.all-tags { color: var(--text-faint); font-weight: 600; cursor: pointer; }
.tag-cloud a.all-tags:hover { color: var(--text); transform: none; }
.tag-cloud[hidden] { display: none; }

.hero-meta {
    margin-top: 16px;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    color: var(--text-faint); font-size: 12.5px;
}

/* ---------- 通用组件 ---------- */

.btn {
    position: relative; overflow: hidden;
    border: 1px solid var(--line); border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #5f6fe8);
    color: #fff; font-size: 14px; padding: 10px 20px; cursor: pointer;
    transition: filter .18s, transform .18s var(--ease-out), box-shadow .2s;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(95, 111, 232, .35); }
.btn:active { transform: translateY(0) scale(.96); }
.btn.ghost { background: transparent; color: var(--text-dim); box-shadow: none; }
.btn.ghost:hover { color: var(--text); background: rgba(148, 163, 184, .1); box-shadow: none; }
.btn:disabled { opacity: .5; cursor: default; }
/* 主按钮悬停扫过一道高光 */
.btn:not(.ghost)::before {
    content: ''; position: absolute; top: 0; left: -70%; width: 45%; height: 100%;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, .32), transparent);
    transform: skewX(-20deg); transition: left .55s ease;
}
.btn:not(.ghost):hover::before { left: 130%; }

.section { padding: 46px 0 10px; }

.section-head { margin-bottom: 20px; }
.section-head h2 { margin: 0; font-size: 24px; }
.section-head p { margin: 6px 0 0; color: var(--text-dim); font-size: 13.5px; }

.state-block {
    padding: 46px 0; text-align: center; color: var(--text-faint); font-size: 14px;
    grid-column: 1 / -1;
}
.state-block.slim { padding: 18px 0; display: flex; align-items: center; justify-content: center; gap: 8px; }

.spinner {
    width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid rgba(148, 163, 184, .3); border-top-color: var(--accent-2);
    animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 滚动显现 ----------
   .reveal 初始隐藏;进入视口后由 JS 加 .in 播放 revealUp,
   --i 控制同批元素的级联延迟(封顶 8 档),播完由 JS 摘掉标记类,
   避免动画 fill 干扰悬停 transform。 */
.reveal { opacity: 0; }
/* 兜底:观察器不触发/动画挂起时由 JS 挂上,内容强制可见 */
.reveal-force { opacity: 1 !important; animation: none !important; }
.reveal.in {
    animation: revealUp .55s var(--ease-out) both;
    animation-delay: calc(min(var(--i, 0), 8) * 45ms);
}
@keyframes revealUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: none; }
}

/* ---------- 栏目筛选(原卡片网格已下线,栏目只以富 chips 呈现) ---------- */

.cat-row { margin-bottom: 16px; }
.cat-row .tag-label { font-size: 12px; color: var(--text-faint); margin-right: 2px; }

/* 每枚栏目 chip 带 --cat-color(内联注入),图标底与悬停描边取栏目主题色 */
#categoryChips .chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 13px 6px 8px; font-size: 13px; font-weight: 500;
}
#categoryChips .chip .ic {
    width: 26px; height: 26px; border-radius: 8px; font-size: 14px;
    display: grid; place-items: center;
    background: color-mix(in srgb, var(--cat-color, var(--accent)) 16%, transparent);
    transition: transform .3s var(--ease-spring);
}
#categoryChips .chip:hover {
    border-color: color-mix(in srgb, var(--cat-color, var(--accent)) 55%, transparent);
    background: color-mix(in srgb, var(--cat-color, var(--accent)) 8%, transparent);
}
#categoryChips .chip:hover .ic { transform: scale(1.1) rotate(-6deg); }
/* 选中态保持全站 accent 渐变,图标底翻白融入渐变 */
#categoryChips .chip.active .ic { background: rgba(255, 255, 255, .2); }
/* 计数从裸数字升级为浅底小胶囊,与「N 条」卡片时期的观感衔接 */
#categoryChips .chip .n {
    margin-left: 1px; opacity: 1; font-size: 11.5px;
    padding: 2px 8px; border-radius: 999px;
    background: rgba(148, 163, 184, .12);
}
#categoryChips .chip.active .n { background: rgba(255, 255, 255, .18); }
#categoryChips .chip-load-fail { font-size: 12.5px; color: var(--text-faint); }

/* ---------- 内容流工具条 ---------- */

.feed-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 12px;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* display:flex 会覆盖 hidden 属性,显式关掉(排序分段/归档条切换显隐用) */
.chip-row[hidden], .seg[hidden] { display: none; }

.chip {
    border: 1px solid var(--line); border-radius: 999px;
    background: transparent; color: var(--text-dim);
    font-size: 13px; padding: 6px 14px; cursor: pointer;
    transition: color .18s, border-color .18s, background .18s, transform .18s var(--ease-out);
}
.chip:hover { color: var(--text); border-color: var(--accent); transform: translateY(-1px); }
.chip:active { transform: scale(.94); }
.chip.active {
    color: #fff; border-color: transparent;
    background: linear-gradient(135deg, var(--accent), #5f6fe8);
}
.chip .n { opacity: .65; font-size: 11.5px; margin-left: 3px; }

.tag-row { margin-bottom: 18px; }
.tag-row .chip { padding: 4px 11px; font-size: 12px; }
.tag-row .tag-label { font-size: 12px; color: var(--text-faint); margin-right: 2px; }
/* 「展开所有标签」:虚线胶囊暗示还有更多,点开全部标签弹层 */
.tag-row .chip.all-tags-btn { border-style: dashed; color: var(--accent-2); }
.tag-row .chip.all-tags-btn:hover { color: var(--text); }

/* 选中标签行:有标签筛选时出现,chip 上的叉号(✕)是取消提示,点整枚即取消 */
.selected-tag-row { margin: -8px 0 18px; }
.selected-tag-row .tag-label { font-size: 12px; color: var(--text-faint); margin-right: 2px; }
.selected-tag-row .chip { padding: 4px 11px; font-size: 12px; }
.selected-tag-row .chip .x { margin-left: 6px; font-size: 11px; opacity: .75; }
.selected-tag-row .chip:hover .x { opacity: 1; }

.day-row { margin: -6px 0 18px; }
.day-row .chip { padding: 4px 11px; font-size: 12px; }
.day-row .tag-label { font-size: 12px; color: var(--text-faint); margin-right: 2px; }

.feed-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

#searchInput {
    width: 220px; max-width: 60vw;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
    color: var(--text); font-size: 13.5px; padding: 9px 12px; outline: none;
}
#searchInput:focus { border-color: var(--accent); }
#searchInput::placeholder { color: var(--text-faint); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
    border: 0; background: transparent; color: var(--text-dim);
    font-size: 13px; padding: 9px 14px; cursor: pointer;
    transition: background .22s ease, color .22s ease;
}
.seg button.active { background: rgba(124, 140, 255, .18); color: var(--text); }

/* ---------- 内容卡片 ---------- */

.card-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 16px;
}

.content-card {
    position: relative;
    display: flex; flex-direction: column;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    cursor: pointer;
    transition: transform .28s var(--ease-spring), background-color .2s, border-color .2s, box-shadow .28s;
}
.content-card:hover {
    background: var(--card-hover);
    border-color: color-mix(in srgb, var(--cat-color, var(--accent)) 40%, transparent);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}
.content-card:active { transform: translateY(-1px) scale(.985); }

/* 鼠标聚光:JS 把指针坐标写进 --mx/--my,叠一层柔和径向光斑 */
.content-card::after {
    content: ''; position: absolute; inset: 0; border-radius: inherit;
    pointer-events: none; opacity: 0;
    background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%),
        color-mix(in srgb, var(--cat-color, var(--accent)) 13%, transparent), transparent 68%);
    transition: opacity .3s ease;
}
.content-card.spot::after { opacity: 1; }

/* rise 只做位移不做淡入:入场可见性绝不依赖动画播完(IAB/遮挡页动画可能冻在首帧) */
@keyframes rise { from { transform: translateY(14px); } }

.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.card-emoji {
    width: 42px; height: 42px; border-radius: 12px; font-size: 21px;
    display: grid; place-items: center; flex: none;
    background: color-mix(in srgb, var(--cat-color, var(--accent)) 18%, transparent);
    transition: transform .35s var(--ease-spring);
}
.content-card:hover .card-emoji { transform: scale(1.12) rotate(-8deg); }

.card-cat {
    font-size: 11.5px; color: var(--cat-color, var(--accent));
    background: color-mix(in srgb, var(--cat-color, var(--accent)) 14%, transparent);
    border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}

.card-badges { margin-left: auto; display: flex; gap: 6px; }
.badge {
    font-size: 10.5px; border-radius: 6px; padding: 2px 7px;
    background: rgba(148, 163, 184, .14); color: var(--text-dim); white-space: nowrap;
}
.badge.pin { background: rgba(34, 211, 238, .16); color: var(--accent-2); }
.badge.hot { background: rgba(244, 114, 182, .16); color: var(--danger); }

.content-card h3 {
    margin: 0 0 8px; font-size: 16px; line-height: 1.45; font-weight: 700;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.content-card .summary {
    margin: 0; color: var(--text-dim); font-size: 13.5px;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
    flex: 1;
}

.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.card-tags span {
    font-size: 11.5px; color: var(--accent-2);
    background: rgba(34, 211, 238, .1); border-radius: 6px; padding: 2px 8px;
}

.card-foot {
    display: flex; align-items: center; gap: 8px; margin-top: 14px;
    color: var(--text-faint); font-size: 12px;
    border-top: 1px dashed var(--line); padding-top: 12px;
}
.card-foot .source { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot .grow { flex: 1; }

/* ---------- 按天分组(日期分区头 + 该日卡片网格) ---------- */

.day-group { margin-bottom: 30px; }
.day-group:last-child { margin-bottom: 0; }
.day-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.day-head::before {
    content: ''; width: 4px; height: 15px; border-radius: 2px; flex: none;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.day-head b { font-size: 15px; letter-spacing: .5px; }
.day-head .day-sub { color: var(--text-faint); font-size: 12.5px; }
.day-head .day-line { flex: 1; border-top: 1px dashed var(--line); }
.day-head .day-count {
    flex: none; font-size: 11.5px; color: var(--text-dim);
    background: rgba(148, 163, 184, .13); border-radius: 999px; padding: 2px 10px;
}

/* ---------- 加载更多 / 空态 ---------- */

.load-more { text-align: center; padding: 26px 0 40px; }
.feed-empty, .feed-end { color: var(--text-faint); font-size: 13px; margin: 0; animation: rise .35s var(--ease-out) both; }

/* ---------- 返回顶部 ---------- */

.to-top {
    position: fixed; right: 22px; bottom: 26px; z-index: 90;
    width: 42px; height: 42px; border-radius: 50%;
    border: 1px solid var(--line); background: var(--card); color: var(--text-dim);
    font-size: 16px; cursor: pointer; box-shadow: var(--shadow);
    opacity: 0; transform: translateY(14px) scale(.9); pointer-events: none;
    transition: opacity .28s ease, transform .28s var(--ease-out),
        color .2s, border-color .2s;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { color: var(--text); border-color: var(--accent); transform: translateY(-2px); }
.to-top:active { transform: scale(.92); }

/* ---------- 详情弹层 ---------- */

.modal-mask {
    position: fixed; inset: 0; z-index: 100;
    background: var(--scrim); backdrop-filter: blur(6px);
    display: grid; place-items: center; padding: 24px;
    animation: maskIn .24s ease both;
}

/* hidden 属性会被上面的 display:grid 覆盖,显式关掉 */
.modal-mask[hidden] { display: none; }

.modal {
    position: relative;
    width: min(720px, 100%); max-height: 86vh; overflow-y: auto;
    /* 预留滚动条槽位:滚动条出现/消失时标题不左右跳 */
    scrollbar-gutter: stable;
    background: var(--bg-soft);
    border: 1px solid var(--line); border-radius: 18px;
    padding: 30px 32px; box-shadow: var(--shadow);
    animation: slideIn .3s cubic-bezier(.25, .46, .45, .94) both;
}

/* 关闭中的出场:面板滑落出屏、遮罩淡出,播完由 JS 置 hidden */
.modal-mask.closing { animation: maskOut .22s ease both; }
.modal-mask.closing .modal { animation: slideOut .22s cubic-bezier(.55, .085, .68, .53) both; }
@keyframes maskIn { from { opacity: 0; } }
@keyframes maskOut { to { opacity: 0; } }
/* 入场:面板整体藏于视口底缘之下(calc(50vh + 50%) 恰好使面板顶边 = 视口底,零空跑零过头),
   纯位移滑到居中位,无展开/缩放。
   曲线用 easeOutQuad:旧 easeOutExpo 型 cubic-bezier(.16,1,.3,1) 前 30% 时长走完 94% 位移
   (尾段 25% 时间只剩 1.6%),视觉上面板瞬移到接近终点再慢慢蹭,即「动画进行到一半突然停住」的来源;
   easeOutQuad 全程平滑减速,尾段 25% 时间仍走 6.25%,收尾可感知。 */
@keyframes slideIn {
    from { transform: translateY(calc(50vh + 50%)); }
    to { transform: none; }
}
/* 出场:easeInQuad,前半段即开始移动(旧 easeInQuart 前一半时间只走 6%,后半突然加速) */
@keyframes slideOut {
    from { transform: none; }
    to { transform: translateY(calc(50vh + 50%)); }
}

/* 详情内容到位后直接替换,不做入场动画 */

.modal-close {
    /* z-index 必须显式高于 modalBody:后者 content-in 动画 fill 期间持有 stacking context,
       同层按 DOM 顺序绘制会把本按钮盖住,导致点不到关闭 */
    position: sticky; top: 0; float: right; margin: -12px -14px 0 0; z-index: 1;
    width: 34px; height: 34px; border-radius: 50%;
    border: 1px solid var(--line); background: var(--card); color: var(--text-dim);
    font-size: 14px; cursor: pointer;
    transition: color .2s, border-color .2s, transform .3s var(--ease-spring);
}
.modal-close:hover { color: var(--text); border-color: var(--accent); transform: rotate(90deg); }

.modal h2 { margin: 6px 46px 0 0; font-size: 22px; line-height: 1.4; }
.modal .meta {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    color: var(--text-faint); font-size: 12.5px; margin-top: 12px;
}
.modal .lead { color: var(--text-dim); font-size: 14.5px; margin: 16px 0 0; }
.modal .body { font-size: 14.5px; line-height: 1.8; white-space: pre-wrap; }
.modal .body + .body { margin-top: 12px; }
.modal .muted-note { color: var(--text-faint); font-style: italic; }

.modal .source-line {
    margin-top: 22px; padding-top: 14px; border-top: 1px dashed var(--line);
    font-size: 13px; color: var(--text-dim);
    display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
}
.modal .source-line a {
    display: inline-block; padding: 7px 16px; border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), #5f6fe8); color: #fff;
    transition: filter .18s, transform .18s var(--ease-out), box-shadow .2s;
}
.modal .source-line a:hover { text-decoration: none; filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(95, 111, 232, .35); }
.modal .source-line a:active { transform: scale(.96); }

/* ---------- 全部标签选择弹层 ---------- */

#tagSearchInput {
    width: 100%; margin-top: 14px;
    background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
    color: var(--text); font-size: 13.5px; padding: 9px 12px; outline: none;
}
#tagSearchInput:focus { border-color: var(--accent); }
#tagSearchInput::placeholder { color: var(--text-faint); }

/* 标签可多到几百个:限高滚动,内部复用 .chip 形态 */
.tag-pick-grid {
    margin-top: 14px;
    display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
    max-height: 52vh; overflow-y: auto; padding-bottom: 4px;
}

/* ---------- 评论区(详情弹层内;未登录可看,登录后可发) ---------- */

.modal .comments {
    margin-top: 26px;
    border-top: 1px dashed var(--line);
    padding-top: 8px;
}
.comments-head h3 {
    margin: 8px 0 0;
    font-size: 16px;
    display: flex; align-items: center; gap: 8px;
}
.comment-count {
    font-size: 11.5px; font-weight: 400;
    color: var(--text-dim);
    background: rgba(148, 163, 184, .13);
    border-radius: 999px; padding: 2px 10px;
}

/* 输入区(已登录):头像 + 身份 + 退出 / 多行输入 / 字数与发送 */
.comment-composer {
    margin-top: 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
}
.composer-who { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.composer-who .avatar { width: 26px; height: 26px; font-size: 12px; }
.composer-who b { font-size: 13.5px; }
.link-btn {
    margin-left: auto;
    border: 0; background: transparent; cursor: pointer;
    color: var(--text-faint); font-size: 12px; padding: 4px 6px;
    transition: color .18s;
}
.link-btn:hover { color: var(--danger); }

#commentInput {
    width: 100%;
    background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
    color: var(--text); font: inherit; font-size: 13.5px; line-height: 1.6;
    padding: 10px 12px; outline: none;
    resize: vertical; min-height: 64px; max-height: 220px;
}
#commentInput:focus { border-color: var(--accent); }
#commentInput::placeholder { color: var(--text-faint); }

.composer-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.composer-foot .btn { padding: 8px 18px; font-size: 13px; }
.comment-error { flex: 1; font-size: 12px; color: var(--danger); }
.char-count { font-size: 11.5px; color: var(--text-faint); }

/* 输入区(未登录):登录引导 */
.login-hint {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    color: var(--text-dim); font-size: 13.5px;
}
.login-hint .btn { margin-left: auto; padding: 8px 18px; font-size: 13px; }

/* 头像:名字首字符,色相按名字散列(同一用户颜色稳定) */
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; flex: none;
    font-size: 14px; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, hsl(var(--h, 220) 62% 52%), hsl(calc(var(--h, 220) + 45) 58% 42%));
}

.comment-list { margin-top: 6px; }
.comment-item {
    display: flex; gap: 10px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--line);
    animation: rise .35s var(--ease-out) both;
}
.comment-item:last-child { border-bottom: 0; }
.comment-main { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: baseline; gap: 8px; }
.comment-meta b { font-size: 13px; }
.comment-meta span { font-size: 11.5px; color: var(--text-faint); }
.comment-text {
    margin: 3px 0 0;
    font-size: 13.5px; line-height: 1.7;
    white-space: pre-wrap; word-break: break-word;
}
.comment-empty { text-align: center; color: var(--text-faint); font-size: 13px; padding: 22px 0; }
.comment-more { text-align: center; padding: 12px 0 4px; }

/* ---------- 登录弹窗 ---------- */

.login-modal { width: min(380px, 100%); }
.login-sub { margin: 8px 0 0; color: var(--text-dim); font-size: 13px; }
.login-form { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.login-form label {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 12.5px; color: var(--text-dim);
}
.login-form input {
    background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
    color: var(--text); font: inherit; font-size: 14px;
    padding: 10px 12px; outline: none;
}
.login-form input:focus { border-color: var(--accent); }
.login-error { margin: 0; font-size: 12.5px; color: var(--danger); }
.btn-block { width: 100%; }

/* ---------- 页脚 ---------- */

.site-footer {
    border-top: 1px solid var(--line);
    padding: 30px 0 40px; margin-top: 30px;
    color: var(--text-faint); font-size: 12.5px; text-align: center;
}
.site-footer p { margin: 6px 0; }
.site-footer .fine { color: rgba(100, 116, 139, .75); }

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

@media (max-width: 720px) {
    .brand-text i { display: none; }
    /* 顶栏兜底:一行装不下时允许换到第二行(右侧操作组整体下移),
       胶囊/站名本身 nowrap + flex:none 已保证不会被压成逐字折行 */
    .header-inner { flex-wrap: wrap; height: auto; min-height: 62px; row-gap: 8px; padding: 8px 0; }
    /* 按钮组间距与桌面版及 /hot 移动版(10px)一致 */
    .header-actions { gap: 10px; }
    .card-grid { grid-template-columns: 1fr; }
    /* 竖排工具条:column 必须配 nowrap。
       保留 wrap 时 flex 会按「假想最大内容宽」算列宽,搜索框的 width:100%
       参与计算会把工具条撑到 600px+,整个页面可横向拖动。 */
    .feed-toolbar { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
    /* 搜索框独占一行(排序/按钮换到下一行);用 flex-basis 而非 width:100%,
       避免百分比宽度参与容器固有宽度计算 */
    #searchInput { flex: 1 1 100%; width: auto; max-width: none; }
    .to-top { right: 14px; bottom: 18px; }

    /* 收紧首屏与分区留白,缩短滑到内容流的距离 */
    .hero, .study-hero { padding: 46px 0 22px; }
    .section { padding: 32px 0 8px; }
    .section-head { margin-bottom: 14px; }
    .overview-grid { gap: 8px; }

    /* 栏目筛选 chips(栏目 + 全部 + 13 栏目):折行太高,改单行横滑;
       负 margin 抵消 .container 内边距,chip 可滑到屏幕边。
       「栏目」文字标签与计数胶囊在窄横滑条里是噪音,藏掉 */
    #categoryChips {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin: 0 -20px;
        padding: 0 20px 2px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        overscroll-behavior-x: contain;
    }
    #categoryChips::-webkit-scrollbar { display: none; }
    #categoryChips .chip { flex: 0 0 auto; scroll-snap-align: start; }
    #categoryChips .tag-label { display: none; }

    /* 弹窗/抽屉等覆盖层滚动面:触摸滚动自带手势反馈,滚动条整个隐藏;
       也避免传统滚动条压住弹窗右缘圆角 */
    .modal, .tag-pick-grid, .ld-tree, .ld-article {
        scrollbar-width: none;
        scrollbar-gutter: auto;
    }
    .modal::-webkit-scrollbar, .tag-pick-grid::-webkit-scrollbar,
    .ld-tree::-webkit-scrollbar, .ld-article::-webkit-scrollbar { display: none; }
}

/* ---------- 动效降级:系统开启「减弱动态效果」时全部即时呈现 ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ============================================================
   目录导航页(/):热点新闻 + 学习资料 两大板块入口
   ============================================================ */

/* ---------- 顶栏汉堡菜单:三站互跳(产品拆解 → 学习资料 → 热点新闻) ----------
   收起时是三横线圆钮(与主题切换按钮同组靠右),展开后下拉列出
   「图标 + 标题」,当前板块高亮为非链接;开关逻辑见 /site-menu.js */
.header-menu { position: relative; display: flex; align-items: center; }

.menu-toggle {
    width: 36px; height: 36px; border-radius: 50%; padding: 0;
    border: 1px solid var(--line); background: var(--card);
    color: var(--text); cursor: pointer;
    display: grid; place-items: center;
    transition: border-color .2s, background .2s, transform .2s var(--ease-spring);
}
.menu-toggle:hover { border-color: var(--accent); transform: scale(1.08); }
.menu-toggle:active { transform: scale(.95); }
.menu-toggle svg { width: 18px; height: 18px; display: block; }
/* 三横线 ↔ 叉:fill-box 让每条线绕自身中心旋转 */
.menu-toggle svg path {
    transform-box: fill-box; transform-origin: center;
    transition: transform .25s var(--ease-out), opacity .18s;
}
.menu-toggle[aria-expanded="true"] {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
    background: color-mix(in srgb, var(--accent) 14%, var(--card));
}
.menu-toggle[aria-expanded="true"] .bar-1 { transform: translateY(5px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .bar-2 { opacity: 0; transform: scaleX(.2); }
.menu-toggle[aria-expanded="true"] .bar-3 { transform: translateY(-5px) rotate(-45deg); }

.site-menu {
    position: absolute; right: 0; top: calc(100% + 10px); z-index: 60;
    min-width: 176px; padding: 6px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--shadow);
    animation: rise .18s var(--ease-out) both;
}
.site-menu[hidden] { display: none; }
.site-menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 8px; border-radius: 8px;
    color: var(--text-dim); font: inherit; font-size: 13.5px;
    white-space: nowrap;
    transition: background .18s, color .18s;
}
a.site-menu-item:hover { background: rgba(148, 163, 184, .1); color: var(--text); text-decoration: none; }
a.site-menu-item:active { transform: scale(.98); }
.site-menu-item .menu-ico {
    width: 30px; height: 30px; border-radius: 9px; flex: none;
    display: grid; place-items: center; font-size: 15px;
    background: linear-gradient(135deg, rgba(124, 140, 255, .25), rgba(34, 211, 238, .18));
    border: 1px solid var(--line);
}
.site-menu-item b { font-weight: 600; }
/* 当前板块:高亮非链接,悬停不再位移 */
.site-menu-item.active {
    color: color-mix(in srgb, var(--accent) 72%, var(--text));
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    cursor: default;
}
.site-menu-item.active .menu-ico { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }

.nav-hero { padding: 84px 0 40px; text-align: center; }
.nav-hero h1 { margin: 10px 0 0; font-size: clamp(30px, 4.6vw, 44px); font-weight: 800; letter-spacing: .5px; }
.nav-hero .hero-sub { margin: 14px auto 0; max-width: 560px; }

.nav-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 20px; margin-top: 44px; text-align: left;
}

.nav-card {
    --nav-color: var(--accent);
    position: relative; display: flex; flex-direction: column;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 26px 26px 22px; color: var(--text); overflow: hidden;
    transition: transform .28s var(--ease-out), border-color .28s, box-shadow .28s;
}
.nav-card::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(360px 200px at 88% -8%, color-mix(in srgb, var(--nav-color) 22%, transparent), transparent 70%);
    opacity: 0; transition: opacity .3s;
    pointer-events: none;
}
.nav-card:hover {
    transform: translateY(-5px);
    border-color: color-mix(in srgb, var(--nav-color) 55%, var(--line));
    box-shadow: 0 16px 40px rgba(2, 6, 23, .5);
    text-decoration: none;
}
.nav-card:hover::before { opacity: 1; }
.nav-card-icon {
    width: 56px; height: 56px; border-radius: 16px; font-size: 28px;
    display: grid; place-items: center; margin-bottom: 16px;
    background: color-mix(in srgb, var(--nav-color) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--nav-color) 35%, transparent);
    transition: transform .3s var(--ease-spring);
}
.nav-card:hover .nav-card-icon { transform: scale(1.1) rotate(-6deg); }
.nav-card h2 { margin: 0 0 8px; font-size: 21px; }
.nav-card-body p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.75; }
.nav-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.nav-card-tags span {
    font-size: 12px; color: color-mix(in srgb, var(--nav-color) 80%, var(--text));
    background: color-mix(in srgb, var(--nav-color) 12%, transparent);
    border-radius: 999px; padding: 2px 10px;
}
.nav-card-go {
    margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 14px; font-weight: 600; color: color-mix(in srgb, var(--nav-color) 85%, var(--text));
}
.nav-card-go span { transition: transform .25s var(--ease-out); }
.nav-card:hover .nav-card-go span { transform: translateX(6px); }

/* 目录页移动端:三张导航大卡 → 紧凑行列表(对齐 /hot 移动版 .m-card 密度)。
   图标 46px 居左,标题 + 简介占右列,标签胶囊与「进入 →」脚注让位(整行可点),
   负 margin 抵消 .container 内边距让分隔线通到屏幕两边。
   (规则放在桌面基础样式之后,同特异性下移动端覆盖才能生效) */
@media (max-width: 720px) {
    .nav-hero { padding: 44px 0 12px; }
    .nav-hero h1 { font-size: 26px; }
    .nav-grid {
        display: flex; flex-direction: column; flex-wrap: nowrap;
        gap: 0; margin: 20px -20px 0;
    }
    .nav-card {
        display: grid; grid-template-columns: 46px minmax(0, 1fr);
        column-gap: 12px; row-gap: 3px; align-items: start;
        padding: 13px 20px; border-radius: 0;
        border: 0; border-bottom: 1px solid var(--line);
        box-shadow: none;
    }
    .nav-card-icon {
        grid-column: 1; grid-row: 1;
        width: 46px; height: 46px; border-radius: 12px; font-size: 23px; margin-bottom: 0;
    }
    /* 拆开 body 包裹层,让标题/简介直接进两列网格 */
    .nav-card-body { display: contents; }
    .nav-card-body h2 { grid-column: 2; margin: 0; font-size: 16px; line-height: 1.4; }
    .nav-card-body p {
        grid-column: 2; margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-dim);
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    }
    .nav-card-tags { display: none; }
    .nav-card-go { display: none; }
}

/* ============================================================
   学习资料(/study):课程列表 + 课程章节页
   ============================================================ */

.study-hero { padding: 64px 0 26px; text-align: center; }

.course-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 20px; margin-top: 34px; text-align: left;
}

.course-card {
    --course-color: var(--accent);
    position: relative; display: flex; flex-direction: column;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 24px; color: var(--text); overflow: hidden; cursor: pointer;
    transition: transform .26s var(--ease-out), border-color .26s, box-shadow .26s;
}
.course-card::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(340px 190px at 85% -6%, color-mix(in srgb, var(--course-color) 24%, transparent), transparent 70%);
    opacity: 0; transition: opacity .3s; pointer-events: none;
}
.course-card:hover {
    transform: translateY(-5px);
    border-color: color-mix(in srgb, var(--course-color) 55%, var(--line));
    box-shadow: 0 16px 40px rgba(2, 6, 23, .5);
}
.course-card:hover::before { opacity: 1; }
.course-emoji {
    width: 52px; height: 52px; border-radius: 15px; font-size: 27px;
    display: grid; place-items: center; margin-bottom: 14px;
    background: color-mix(in srgb, var(--course-color) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--course-color) 32%, transparent);
    transition: transform .3s var(--ease-spring);
}
.course-card:hover .course-emoji { transform: scale(1.1) rotate(-6deg); }
.course-card h3 { margin: 0 0 4px; font-size: 19px; }
.course-card .course-sub { margin: 0 0 10px; color: var(--text-dim); font-size: 13px; }
.course-card .course-desc { margin: 0; color: var(--text-dim); font-size: 13.5px; line-height: 1.7;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.course-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 4px; }
.course-meta span {
    font-size: 12px; border-radius: 999px; padding: 2px 10px;
    background: color-mix(in srgb, var(--course-color) 12%, transparent);
    color: color-mix(in srgb, var(--course-color) 80%, var(--text));
}
.course-meta span.muted { background: rgba(148, 163, 184, .12); color: var(--text-dim); }
.course-go { margin-top: auto; padding-top: 16px; font-size: 13.5px; font-weight: 600;
    color: color-mix(in srgb, var(--course-color) 85%, var(--text)); }

/* 课程章节页头 */
.course-head {
    --course-color: var(--accent);
    position: relative; overflow: hidden;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 30px; margin-top: 26px;
}
.course-head::before {
    content: ''; position: absolute; inset: 0;
    background:
        radial-gradient(420px 220px at 90% -10%, color-mix(in srgb, var(--course-color) 26%, transparent), transparent 70%);
    pointer-events: none;
}
.course-head-top { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.course-head-emoji { font-size: 44px; line-height: 1; }
.course-head h1 { margin: 2px 0 6px; font-size: 27px; }
.course-head .course-sub { color: var(--text-dim); margin: 0 0 10px; }
.course-head .course-desc { color: var(--text-dim); max-width: 720px; line-height: 1.8; margin: 0 0 12px; }

/* 课时列表 */
.lesson-list { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
.lesson-row {
    display: flex; align-items: center; gap: 16px; text-align: left; cursor: pointer;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 20px; color: var(--text);
    transition: transform .22s var(--ease-out), border-color .22s, background .22s;
}
.lesson-row:hover { transform: translateX(4px); border-color: var(--accent); background: var(--card-hover); }
.lesson-index {
    flex: none; width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center; font-weight: 800; font-size: 15px;
    background: color-mix(in srgb, var(--course-color, var(--accent)) 14%, transparent);
    color: color-mix(in srgb, var(--course-color, var(--accent)) 85%, var(--text));
    border: 1px solid color-mix(in srgb, var(--course-color, var(--accent)) 30%, transparent);
}
.lesson-main { flex: 1; min-width: 0; }
.lesson-main h3 { margin: 0 0 3px; font-size: 16px; }
.lesson-main p { margin: 0; color: var(--text-dim); font-size: 13px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.lesson-progress { width: 120px; height: 5px; border-radius: 999px; background: rgba(148, 163, 184, .18); overflow: hidden; }
.lesson-progress i { display: block; height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.lesson-stats { font-size: 12px; color: var(--text-faint); }

/* ---------- 学习资料移动端:课程列表改紧凑行(对齐 /hot 移动版 .m-card),首屏/课时行/阅读抽屉收紧 ---------- */
@media (max-width: 720px) {
    /* 课程卡两段式:上段 emoji + 标题垂直居中;下段简介/标签通栏排布,左缘与图标对齐。
       长描述与「开始学习 →」让位(整行可点) */
    .course-grid {
        display: flex; flex-direction: column; flex-wrap: nowrap;
        gap: 0; margin: 20px -20px 0;
    }
    .course-card {
        display: grid; grid-template-columns: 46px minmax(0, 1fr);
        column-gap: 12px; row-gap: 6px; align-items: center;
        padding: 13px 20px; border-radius: 0;
        border: 0; border-bottom: 1px solid var(--line);
        box-shadow: none;
    }
    .course-emoji {
        grid-column: 1; grid-row: 1;
        width: 46px; height: 46px; border-radius: 12px; font-size: 23px; margin-bottom: 0;
    }
    .course-card h3 { grid-column: 2; grid-row: 1; margin: 0; font-size: 15.5px; line-height: 1.4; }
    /* 桌面基础规则是 .course-card .course-sub / .course-desc(两级类名),这里保持同级特异性才能覆盖 */
    .course-card .course-sub {
        grid-column: 1 / -1; margin: 0; font-size: 12.5px;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .course-card .course-sub:empty { display: none; }
    .course-card .course-desc { display: none; }
    .course-meta { grid-column: 1 / -1; margin: 0; }
    /* 标签/👁 等灰胶囊在窄行里是噪音,只留难度与节数 */
    .course-meta span.muted { display: none; }
    .course-go { display: none; }
    .course-head { padding: 20px; margin-top: 18px; }
    .course-head-emoji { font-size: 36px; }
    .course-head h1 { font-size: 22px; }
    .stage-block { margin-top: 26px; }
    .chapter-block { margin-top: 20px; }
    .chapter-head { flex-wrap: wrap; }
    /* 课时行:序号与右侧信息缩小,👁 统计让位给标题 */
    .lesson-row { padding: 14px; gap: 12px; }
    .lesson-index { width: 34px; height: 34px; border-radius: 10px; font-size: 13.5px; }
    .lesson-side { gap: 5px; }
    .lesson-stats { display: none; }
    /* 阅读抽屉:顶栏/正文边距收紧,图片放大层贴边 */
    .ld-header { gap: 10px; padding: 8px 12px; }
    .ld-tree-btn { padding: 0 12px; }
    .ld-article { padding: 22px 16px 32px; }
    .ld-footer { gap: 10px; margin-top: 26px; }
    .reader-nav { padding: 12px 14px; }
    .imgview-mask { padding: 12px; }
}

/* ============================================================
   节阅读弹层(课程页点击某一节,全屏展开)
   左侧 VSCode 文件树风格课程目录(阶段 → 章 → 节,字号加大)+ 右侧正文
   ============================================================ */

body.drawer-lock { overflow: hidden; }

/* 遮罩:点击关闭;抽屉在遮罩之上,图片放大层在最上 */
.ld-scrim {
    position: fixed; inset: 0; z-index: 58;
    background: var(--scrim); backdrop-filter: blur(3px);
    opacity: 0; transition: opacity .26s; cursor: pointer;
}
.ld-scrim.show { opacity: 1; }

.lesson-drawer {
    --course-color: var(--accent);
    position: fixed; inset: 0; z-index: 60;
    display: flex; flex-direction: column;
    background: var(--bg);
    transform: translateX(103%); visibility: hidden;
    transition: transform .34s var(--ease-out), visibility 0s .34s;
}
.lesson-drawer.open { transform: translateX(0); visibility: visible; transition: transform .34s var(--ease-out); }

/* --- 抽屉顶栏 --- */
.ld-header {
    flex: none; display: flex; align-items: center; gap: 14px;
    padding: 10px 18px; border-bottom: 1px solid var(--line);
    background: var(--header-bg); backdrop-filter: blur(14px);
}
.ld-close {
    flex: none; width: 36px; height: 36px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--card); color: var(--text-dim);
    font: 600 15px/1 inherit; cursor: pointer;
    transition: color .18s, border-color .18s, background .18s;
}
.ld-close:hover { color: var(--text); border-color: var(--accent); background: var(--card-hover); }
.ld-title { flex: 1; min-width: 0; }
.ld-title b { display: block; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ld-title span { font-size: 12.5px; color: var(--text-faint); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; display: block; }
.ld-tree-btn, .ld-theme {
    flex: none; height: 36px; padding: 0 14px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--card); color: var(--text-dim);
    font: 600 13.5px/34px inherit; cursor: pointer;
    transition: color .18s, border-color .18s, background .18s;
}
.ld-tree-btn:hover, .ld-theme:hover { color: var(--text); border-color: var(--accent); background: var(--card-hover); }
.ld-tree-btn { display: none; }
/* 抽屉内主题按钮:只放 SVG 图标,固定圆角方块并居中 */
.ld-theme { display: inline-flex; align-items: center; justify-content: center; width: 36px; padding: 0; }

/* --- 目录树(左)+ 正文(右)两栏 ---
   目录固定 322px 靠左;正文占剩余空间,内容列 860px 在其中居中
   (屏幕宽 → 内容居中;屏幕窄 → 内容贴着目录靠右铺开) */
.ld-body {
    flex: 1; min-height: 0; position: relative;
    display: grid; grid-template-columns: 322px minmax(0, 1fr);
}
.ld-article {
    min-width: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: 30px clamp(20px, 4vw, 52px) 40px;
}
.ld-article-inner { max-width: 860px; margin: 0 auto; }
/* 章节切换过渡:旧内容先淡出(.leaving),新内容淡入上浮(.swap) */
.ld-article-inner { transition: opacity .16s ease; }
.ld-article-inner.leaving { opacity: .25; }
@keyframes ldSwapIn {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}
.ld-article-inner.swap { animation: ldSwapIn .34s var(--ease-out); }
@media (prefers-reduced-motion: reduce) {
    .ld-article-inner.swap { animation: none; }
    .ld-article-inner { transition: none; }
}
.ld-meta { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
    font-size: 12.5px; color: var(--text-faint); margin-bottom: 6px; }
.ld-meta .chapter-chip {
    border-radius: 999px; padding: 2px 10px;
    background: color-mix(in srgb, var(--course-color, var(--accent)) 12%, transparent);
    color: color-mix(in srgb, var(--course-color, var(--accent)) 80%, var(--text));
}
.ld-h1 { margin: 6px 0 4px; font-size: clamp(22px, 3vw, 29px); font-weight: 800; line-height: 1.35; }
.ld-summary { margin: 0 0 8px; color: var(--text-dim); font-size: 14.5px; line-height: 1.7; }
.ld-summary:empty { display: none; }
.ld-article .md-body { font-size: 15.5px; }
.ld-article .md-body h1 { font-size: 24px; }

/* --- 底部上/下一节 --- */
.ld-footer {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
    margin-top: 34px; padding-top: 6px;
}
.reader-nav {
    display: flex; flex-direction: column; gap: 5px; text-align: left; cursor: pointer;
    border: 1px solid var(--line); border-radius: 14px; background: var(--card);
    color: var(--text); font: inherit; padding: 14px 18px; min-width: 0;
    transition: border-color .2s, transform .2s var(--ease-out), background .2s;
}
.reader-nav:hover { border-color: var(--accent); background: var(--card-hover); transform: translateY(-2px); text-decoration: none; }
.reader-nav.next { text-align: right; grid-column: 2; }
.reader-nav:disabled { opacity: .35; cursor: default; transform: none; }
.reader-nav:disabled:hover { border-color: var(--line); background: var(--card); }
.reader-nav .rn-label { font-size: 12px; color: var(--text-faint); }
.reader-nav .rn-title { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- 左侧课程目录树(VSCode 文件树风格,字号加大) --- */
.ld-tree {
    order: -1; /* DOM 中目录在正文后,网格里排到左边一列 */
    min-width: 0; overflow-y: auto; overscroll-behavior: contain;
    border-right: 1px solid var(--line);
    padding: 16px 10px 30px 6px;
    background: color-mix(in srgb, var(--bg-soft) 55%, var(--bg));
}
.ld-tree-title { font-size: 12px; letter-spacing: 2px; color: var(--text-faint);
    text-transform: uppercase; margin: 2px 0 10px 10px; }
.ftree-row {
    display: flex; align-items: center; gap: 4px;
    min-height: 40px; padding: 0 10px 0 12px; border-radius: 9px;
    color: var(--text-dim); cursor: default; user-select: none;
}
.ftree-twist { flex: none; width: 18px; text-align: center; font-size: 12px;
    color: var(--text-faint); font-style: normal; }
.ftree-icon { flex: none; width: 24px; text-align: center; font-size: 15px; }
.ftree-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ftree-badge { flex: none; margin-left: 8px; font-size: 12px; color: var(--text-faint); }

/* 阶段/章行:可折叠,悬停青景 */
.ftree-stage, .ftree-chapter { cursor: pointer; }
.ftree-stage { font-size: 15.5px; font-weight: 700; color: var(--text); }
.ftree-chapter { font-size: 15px; font-weight: 600; }
.ftree-stage:hover, .ftree-chapter:hover { background: var(--card-hover); }

/* 节(叶子):点击阅读;当前节高亮 + 左侧色条;已读打勾置灰 */
.ftree-leaf { font-size: 14.5px; cursor: pointer; }
.ftree-leaf:hover { background: var(--card-hover); color: var(--text); }
.ftree-leaf.current {
    background: color-mix(in srgb, var(--course-color, var(--accent)) 16%, transparent);
    color: var(--text); font-weight: 600;
    box-shadow: inset 3px 0 0 var(--course-color, var(--accent));
}
.ftree-leaf.read .ftree-label { color: var(--text-faint); }
.ftree-leaf.read::after { content: '✓'; flex: none; font-size: 13px; color: #2fbf71; padding-right: 2px; }

/* 层级缩进 + VSCode 式缩进参考线;默认收起,.open 展开 */
.ftree-kids { margin-left: 21px; border-left: 1px solid var(--line); display: none; }
.ftree-node.open > .ftree-kids { display: block; }

/* 窄屏:目录树变成可从左侧拉出的覆盖层 */
@media (max-width: 1100px) {
    .ld-body { grid-template-columns: minmax(0, 1fr); }
    /* 收起时 visibility:hidden 且不带投影:
       旧写法只 translateX(-103%) 收起,box-shadow 仍会绘制,
       浅色模式下屏幕左缘会压出一条明显的黑色阴影带 */
    .ld-tree {
        position: absolute; top: 0; left: 0; bottom: 0; width: min(348px, 88vw); max-width: none;
        background: var(--bg-soft);
        transform: translateX(-103%); visibility: hidden;
        transition: transform .3s var(--ease-out), visibility 0s .3s;
        border-right: 1px solid var(--line);
    }
    /* 投影只在拉出后才挂,浅色模式再降一档浓度 */
    .lesson-drawer.tree-open .ld-tree {
        transform: translateX(0); visibility: visible;
        transition: transform .3s var(--ease-out);
        box-shadow: 16px 0 40px rgba(2, 6, 23, .5);
    }
    body.light .lesson-drawer.tree-open .ld-tree { box-shadow: 12px 0 32px rgba(15, 23, 42, .18); }
    .ld-tree-btn { display: inline-flex; align-items: center; }
    .ld-footer { grid-template-columns: 1fr; }
    .reader-nav.next { grid-column: 1; }
}

/* ============================================================
   markdown 正文(.md-body):阅读页与图片共用
   ============================================================ */

.md-body { line-height: 1.8; color: var(--text-dim); word-break: break-word; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4, .md-body h5 {
    margin: 1.3em 0 .5em; line-height: 1.4; color: var(--text);
}
.md-body h1 { font-size: 22px; font-weight: 800; }
.md-body h2 { font-size: 21px; font-weight: 800; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.md-body h3 { font-size: 17.5px; font-weight: 700; }
.md-body h4 { font-size: 15.5px; font-weight: 700; color: var(--accent); }
.md-body h5 { font-size: 14.5px; font-weight: 700; }
.md-body h1:first-child, .md-body h2:first-child, .md-body h3:first-child,
.md-body h4:first-child, .md-body h5:first-child { margin-top: 0; }
.md-body p { margin: .55em 0; }
.md-body strong { color: var(--text); font-weight: 700; }
.md-body em { color: var(--text); }
.md-body del { color: var(--text-faint); }
.md-body a { color: var(--accent-2); }
.md-body a:hover { text-decoration: underline; }
.md-body code {
    font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: rgba(124, 140, 255, .12); color: var(--accent-2);
    padding: 2px 7px; border-radius: 6px; word-break: break-word;
}
.md-body pre {
    margin: .8em 0; padding: 16px 18px; border-radius: 12px; overflow: auto;
    background: rgba(2, 6, 23, .55); border: 1px solid var(--line);
    font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #c8d3f5; max-height: 560px;
}
/* 浅色主题:代码块换 GitHub 风格浅底,token 配色见下方 body.light .hljs-* 一组 */
body.light .md-body pre {
    background: #f6f8fa;
    border-color: #d5dbe3;
    color: #24292e;
}
.md-body pre code { background: none; padding: 0; color: inherit; font: inherit; word-break: normal; }
.md-body blockquote {
    margin: .8em 0; padding: 10px 16px; border-left: 3px solid var(--accent);
    background: rgba(148, 163, 184, .08); border-radius: 0 12px 12px 0;
}
.md-body blockquote p { margin: .3em 0; }
.md-body ul, .md-body ol { margin: .5em 0; padding-left: 24px; display: flex; flex-direction: column; gap: 6px; }
.md-body li::marker { color: var(--accent); }
.md-body li > ul, .md-body li > ol { margin: 6px 0 0; }
.md-body hr { border: none; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md-body img {
    max-width: 100%; height: auto; border-radius: 12px;
    border: 1px solid var(--line); background: #fff; cursor: zoom-in;
}
.md-body figure { margin: 1em 0; text-align: center; }
.md-body figure img { max-width: 100%; }
.md-body figcaption { margin-top: 8px; font-size: 12.5px; color: var(--text-faint); }
.md-body table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: .8em 0; display: block; overflow-x: auto; }
.md-body th, .md-body td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; line-height: 1.6; }
.md-body th { background: rgba(124, 140, 255, .10); color: var(--text); font-weight: 700; white-space: nowrap; }
.md-body tbody tr:nth-child(even) { background: rgba(148, 163, 184, .05); }

/* --- highlight.js 代码高亮(自配双色主题,随 body.light 切换) --- */
.hljs-keyword, .hljs-selector-tag, .hljs-meta-keyword, .hljs-doctag { color: #c792ea; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #a5e075; }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: #f78c6c; }
.hljs-title, .hljs-section, .hljs-name, .hljs-selector-id, .hljs-selector-class { color: #82aaff; }
.hljs-comment, .hljs-quote, .hljs-deletion { color: #6b7394; font-style: italic; }
.hljs-function .hljs-title, .hljs-title.function_ { color: #ffd580; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-type { color: #ffcb6b; }
.hljs-built_in, .hljs-builtin-name { color: #4ec9b0; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }
body.light .hljs-keyword, body.light .hljs-selector-tag, body.light .hljs-meta-keyword, body.light .hljs-doctag { color: #d73a49; }
body.light .hljs-string, body.light .hljs-regexp, body.light .hljs-addition { color: #032f62; }
body.light .hljs-number, body.light .hljs-literal, body.light .hljs-symbol, body.light .hljs-bullet { color: #005cc5; }
body.light .hljs-title, body.light .hljs-section, body.light .hljs-name,
body.light .hljs-selector-id, body.light .hljs-selector-class { color: #6f42c1; }
body.light .hljs-comment, body.light .hljs-quote, body.light .hljs-deletion { color: #6a737d; }
body.light .hljs-function .hljs-title, body.light .hljs-title.function_ { color: #e36209; }
body.light .hljs-attr, body.light .hljs-attribute, body.light .hljs-variable,
body.light .hljs-template-variable, body.light .hljs-type { color: #b58900; }
body.light .hljs-built_in, body.light .hljs-builtin-name { color: #22863a; }

/* --- 图片放大查看(点击正文图片) --- */
.imgview-mask {
    position: fixed; inset: 0; z-index: 70; background: var(--scrim);
    display: flex; align-items: center; justify-content: center; padding: 30px;
    cursor: zoom-out; backdrop-filter: blur(6px);
}
.imgview-mask[hidden] { display: none; }
.imgview-mask img { max-width: 100%; max-height: 100%; border-radius: 12px; }

/* --- 课程页阶段/章分组(阶段 → 章 → 节) --- */
.stage-block { margin-top: 36px; }
.stage-head {
    display: flex; align-items: baseline; gap: 12px;
    padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line);
}
.stage-head h2 { margin: 0; font-size: 21px; font-weight: 800; }
.chapter-block { margin-top: 26px; }
.chapter-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.chapter-no {
    flex: none; font-size: 13px; font-weight: 800; letter-spacing: 1px;
    color: color-mix(in srgb, var(--course-color, var(--accent)) 85%, var(--text));
}
.chapter-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.chapter-count { font-size: 12.5px; color: var(--text-faint); }

.lesson-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.read-badge {
    flex: none; font-size: 12px; border-radius: 999px; padding: 2px 10px;
    background: rgba(47, 191, 113, .14); color: #2fbf71; white-space: nowrap;
}
.read-badge.unread { background: rgba(148, 163, 184, .12); color: var(--text-faint); }
.lesson-stats { font-size: 12px; color: var(--text-faint); }

@media (prefers-reduced-motion: reduce) {
    .reader-nav:hover { transform: none; }
}

/* ---------- 2026-10-24 补:整卡可点的链接不加悬停下划线(盖掉全局 a:hover) ---------- */
a.nav-card, a.nav-card:hover, a.nav-card *,
a.course-card, a.course-card:hover, a.course-card * {
    text-decoration: none;
}
