/* ============================================================
   AI 奇妙课堂 · 合并版 shell 样式（4 主题 60 课）
   ------------------------------------------------------------
   布局参考 Python/C++ 课：站点顶栏 + 左侧主题目录 + 右侧内容区。
   - 只负责 shell  chrome（侧栏 / 内容栏 / 加载屏 / 通关卡），
     课程本体样式全部来自 themes/*.css（已按 #app[data-tk] 作用域隔离）。
   - 主题 CSS 里的 body 级元素（#confetti/.sim-banner/#aipFab…）
     在其文件内保持全局，这里不重复定义，避免互相覆盖。
   ============================================================ */

/* ---------- 基础 ---------- */
html, body { margin: 0; padding: 0; }
body {
  height: 100vh;
  height: 100dvh;                   /* 移动端地址栏收放时不跳动 */
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;                 /* 页面本体不滚，#app 内部滚 */
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
.merge-layout * { box-sizing: border-box; }
.merge-layout { flex: 1; min-height: 0; display: flex; position: relative; z-index: 1; }

/* ---------- 左侧主题目录 ---------- */
#sidebar {
  width: 286px; flex: 0 0 286px; height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  display: flex; flex-direction: column;
  position: relative; z-index: 2;
}
.side-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.side-title {
  font-family: "Orbitron", "PingFang SC", sans-serif;
  font-size: 15px; font-weight: 700; letter-spacing: .5px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.side-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
/* 四大主题切换（始终可见）：2×2 紧凑标签，下面只列当前主题的 15 课 */
.theme-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.theme-tab {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  padding: 7px 8px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(74, 58, 36, .45);
  color: var(--muted); font-family: inherit; text-align: left;
}
.theme-tab:hover { border-color: rgba(255, 198, 92, .45); color: var(--text); }
.theme-tab.active {
  background: var(--grad-soft); color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(255, 198, 92, .30);
}
.tt-emoji { font-size: 15px; flex: 0 0 auto; }
.tt-name { flex: 1; min-width: 0; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-count { flex: 0 0 auto; font-family: "Orbitron", sans-serif; font-size: 10.5px; color: var(--muted); }
.tt-count b { color: var(--cyan); font-weight: 700; }
.nav-caption {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 4px 8px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted);
}
.nav-caption span { color: var(--cyan); font-size: 10.5px; white-space: nowrap; }
.nav-empty { padding: 20px 10px; color: var(--muted); font-size: 12px; text-align: center; }

/* 总进度环（与 Python 课同款：SVG 圆环 + 百分比） */
.prog-wrap { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.ring { width: 46px; height: 46px; flex: 0 0 46px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4.5; }
.ring-bg { stroke: var(--line); }
.ring-fg {
  stroke: var(--cyan); stroke-linecap: round;
  stroke-dasharray: 119.4; stroke-dashoffset: 119.4;
  filter: drop-shadow(0 0 6px rgba(255, 198, 92, .55));
  transition: stroke-dashoffset .5s ease;
}
.prog-txt { display: flex; flex-direction: column; line-height: 1.35; }
.prog-txt b { font-size: 17px; font-family: "Orbitron", sans-serif; color: var(--cyan); }
.prog-txt span { font-size: 11.5px; color: var(--muted); }

.side-search { margin-top: 12px; }
.side-search input {
  width: 100%; padding: 7px 11px; font-size: 12.5px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(74, 58, 36, .6); color: var(--text);
  font-family: inherit;
}
.side-search input::placeholder { color: var(--muted); }
.side-search input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 22px rgba(255, 198, 92, .35); }

#sideNav { flex: 1; overflow-y: auto; padding: 10px 8px 20px; }

/* 主题组 */
.theme-group { margin-bottom: 6px; }
.theme-head {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px; border: 0; background: none; color: var(--text);
  border-radius: 9px; text-align: left; cursor: pointer; font-family: inherit;
}
.theme-head:hover { background: rgba(74, 58, 36, .6); }
.theme-group.active > .theme-head {
  background: var(--grad-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 198, 92, .30);
}
.t-emoji { font-size: 17px; flex: 0 0 auto; }
.t-meta { flex: 1; min-width: 0; }
.t-name { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.t-sub b { color: var(--cyan); font-weight: 700; }
.t-tag {
  display: inline-block; padding: 0 6px; border-radius: 999px; font-size: 10px;
  background: var(--grad-soft); color: var(--cyan); border: 1px solid rgba(255, 198, 92, .25);
}
.t-chev { color: var(--muted); font-size: 11px; flex: 0 0 auto; transition: transform .2s; }
.theme-group.collapsed .t-chev { transform: rotate(-90deg); }
.theme-group.collapsed .theme-lessons { display: none; }

.theme-lessons {
  padding: 2px 0 8px 12px; margin-left: 18px;
  border-left: 1.5px solid var(--line);
}
.lesson-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; margin-bottom: 1px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-size: 12.8px;
}
.lesson-item:hover { background: rgba(74, 58, 36, .6); color: var(--text); }
.lesson-item.active {
  background: var(--grad-soft); color: var(--cyan); font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 198, 92, .30);
}
.lesson-item.search-hit { background: var(--grad-soft); color: var(--cyan); }
.l-num {
  flex: 0 0 22px; text-align: center;
  font-family: "Orbitron", sans-serif; font-size: 11px; color: var(--muted);
}
.lesson-item.active .l-num { color: var(--cyan); }
.lesson-item.done .l-num { color: var(--lime); }
.l-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.l-state { flex: 0 0 auto; min-width: 20px; text-align: right; font-size: 11px; color: var(--muted); }
.lesson-item.done .l-state { color: var(--lime); font-weight: 700; }
.lab-item .l-num { font-size: 13px; }

/* 侧栏底部「课程总览」按钮已移除（2026-11-17）：课程目录 #sideNav flex:1 自动填满，
   原 .side-foot / .mini / .side-home-btn 死样式一并删除。 */

/* ---------- 右侧内容区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.content-bar {
  height: 50px; flex: 0 0 50px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; background: rgba(26, 21, 13, .72);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.crumb {
  flex: 1; min-width: 0; font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb-sep { color: var(--line); margin: 0 2px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  padding: 6px 12px; font-size: 12.5px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(74, 58, 36, .6); color: var(--muted);
  font-family: inherit; white-space: nowrap;
  transition: border-color .15s, color .15s, box-shadow .15s;
}
.nav-btn:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 22px rgba(255, 198, 92, .35); }
.nav-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn { border: 0; background: none; font-size: 19px; color: var(--muted); padding: 4px 8px; cursor: pointer; }
.icon-btn:hover { color: var(--cyan); }
.only-mobile { display: none; }

/* 课程内容：内部滚动（主题样式作用域在 #app[data-tk] 上） */
#app { flex: 1; min-height: 0; overflow-y: auto; position: relative; }

/* 合并页自带移动端目录（#btnMenu），隐藏 dm-ui.js 注入的旧「本节导航」悬浮按钮 */
#dm-nav-toggle, #dm-nav-mask { display: none !important; }

/* ---------- 通关卡（shell.js 覆写 CourseEnd.mount 后自绘，样式从 course-end.js 抄来） ---------- */.ce-card {
  margin: 26px auto 8px; max-width: 760px;
  background: linear-gradient(120deg, rgba(255, 198, 92, .1), rgba(255, 157, 176, .1));
  border: 1px solid var(--line); border-radius: 18px; padding: 24px 26px; text-align: center;
}
.ce-card h3 { margin: 6px 0 4px; font-size: 22px; }
.ce-sub { color: var(--muted); font-size: 14px; line-height: 1.7; margin: 0 0 16px; }
.ce-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.ce-btn {
  border: 0; border-radius: 12px; padding: 12px 20px; cursor: pointer;
  font-size: 15px; font-weight: 700; font-family: inherit;
}
.ce-btn.primary { background: linear-gradient(90deg, #ffc65c, #ff9db0); color: #2b1c05; }
.ce-btn:not(.primary) { background: rgba(160, 140, 100, .16); color: inherit; border: 1px solid var(--line); }

/* ---------- 加载屏（各主题 #loader 样式在作用域化时被丢弃，这里自带） ---------- */
#loader {
  position: fixed; inset: 0; z-index: 999; background: var(--bg);
  display: flex; align-items: center; justify-content: center; transition: opacity .6s;
}
#loader.hide { opacity: 0; pointer-events: none; }
.loader-core { text-align: center; color: var(--muted); font-family: "Orbitron", "PingFang SC", sans-serif; }
.loader-core span { display: block; margin-top: 18px; letter-spacing: 2px; font-size: 13px; }
.ld-ring {
  width: 84px; height: 84px; margin: 0 auto; border-radius: 50%;
  border: 3px solid transparent; border-top-color: var(--cyan); border-right-color: var(--purple);
  animation: ld-spin 1s linear infinite;
}
.ld-ring.r2 {
  width: 60px; height: 60px; margin: -72px auto 0;
  border-top-color: var(--pink); animation: ld-spin 1.4s linear infinite reverse;
}
@keyframes ld-spin { to { transform: rotate(360deg); } }

/* ---------- 滚动条 ---------- */
#sideNav::-webkit-scrollbar, #app::-webkit-scrollbar { width: 9px; height: 9px; }
#sideNav::-webkit-scrollbar-track, #app::-webkit-scrollbar-track { background: transparent; }
#sideNav::-webkit-scrollbar-thumb, #app::-webkit-scrollbar-thumb {
  background: rgba(255, 198, 92, .30); border-radius: 99px;
}
#sideNav::-webkit-scrollbar-thumb:hover, #app::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 198, 92, .55);
}

/* ---------- 响应式：窄屏侧栏变抽屉 ---------- */
@media (max-width: 900px) {
  .only-mobile { display: block; }
  #sidebar {
    position: fixed; z-index: 200; left: 0; top: 59px; bottom: 0; height: auto;
    transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow);
  }
  body.side-open #sidebar { transform: none; }
  .content-bar { padding: 0 10px; gap: 6px; }
  .nav-btn { padding: 6px 9px; font-size: 12px; }
}

/* ---------- 首页：4 门可折叠课程（单屏，不产生页面滚动） ---------- */
.home-wrap {
  max-width: 1180px; margin: 0 auto; padding: 16px 22px 18px;
  min-height: 100%; display: flex; flex-direction: column; gap: 12px;
}
.home-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.home-head h1 {
  font-size: 25px; margin: 0; font-weight: 900; letter-spacing: .01em;
  background: linear-gradient(96deg,#ffc65c,#ff9db0 68%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.home-stat { font-size: 12.5px; color: #c9b795; }
.home-stat b { color: #ffc65c; font-size: 14px; }
.dm-resume-wrap { flex: 0 0 auto; }

.course-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px; align-items: start; align-content: start;
}
.course-card {
  position: relative; overflow: hidden;
  background: #201a12; border: 1px solid #3a2f1e; border-radius: 14px;
  transition: border-color .18s, box-shadow .18s;
}
.course-card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--c), transparent);
}
.course-card:hover, .course-card[open] { border-color: var(--c); box-shadow: 0 10px 28px rgba(255,198,92,.12); }
.cc-head {
  display: flex; align-items: center; gap: 11px; cursor: pointer;
  padding: 13px 14px; list-style: none;
}
.cc-head::-webkit-details-marker { display: none; }
.cc-ico {
  width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center;
  font: 800 12.5px/1 'PingFang SC','Microsoft YaHei',sans-serif;
  color: var(--c); background: var(--cbg); border: 1px solid #3a2f1e;
}
.cc-name { flex: 1; min-width: 0; font-size: 16px; font-weight: 800; line-height: 1.25; color: #fdf4e3; }
.cc-name small {
  display: block; margin-top: 2px; font-size: 10.5px; letter-spacing: .1em;
  color: #9a8768; font-weight: 700; text-transform: uppercase;
}
.cc-count {
  flex: none; font-size: 12px; font-weight: 800; color: var(--c); background: var(--cbg);
  border: 1px solid #3a2f1e; padding: 2px 9px; border-radius: 999px;
}
.cc-caret { flex: none; color: #9a8768; font-size: 12px; transition: transform .2s; }
.course-card[open] .cc-caret { transform: rotate(180deg); color: var(--c); }

.cc-body { padding: 0 14px 13px; }
.cc-desc { margin: 0 0 9px; font-size: 12.5px; line-height: 1.6; color: #c9b795; }
.cc-bar { height: 4px; border-radius: 3px; background: #3a2f1e; overflow: hidden; margin-bottom: 10px; }
.cc-bar i { display: block; height: 100%; border-radius: 3px; background: var(--c); transition: width .4s ease; }
/* 课表在卡内滚动：展开也不会把首页撑出滚动条 */
.cc-lessons {
  list-style: none; margin: 0 0 10px; padding: 0 4px 0 0;
  max-height: 168px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--c) #2a2217;
}
.cc-lessons::-webkit-scrollbar { width: 6px; }
.cc-lessons::-webkit-scrollbar-track { background: #2a2217; border-radius: 3px; }
.cc-lessons::-webkit-scrollbar-thumb { background: var(--c); border-radius: 3px; opacity: .7; }
.cc-lesson {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 8px;
  text-decoration: none; color: #c9b795; font-size: 12.5px; line-height: 1.4;
}
.cc-lesson:hover { background: var(--cbg); color: #fdf4e3; }
.cc-lesson .n { flex: none; font: 700 11px/1 'SF Mono',Consolas,monospace; color: #9a8768; }
.cc-lesson .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 2026-11-24：课名主标题+副标题小字，副标题跟在主标题后（单行省略，鼠标悬浮 title 看全名） */
.cc-lesson .t small { display: inline; margin-left: 6px; font-size: 11px; opacity: .62; font-weight: 400; }
.cc-lesson .s { flex: none; width: 14px; text-align: right; color: var(--c); font-weight: 800; }
.cc-lesson.done { color: #fdf4e3; }
.cc-cta {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  font-size: 12.5px; font-weight: 800; color: var(--c);
}
.cc-cta s { text-decoration: none; transition: transform .2s ease; }
.cc-cta:hover s { transform: translateX(4px); }
/* 独立壳板块外链卡片（整卡跳转，不展开课表） */
.ext-card { display: block; text-decoration: none; }
.ext-card .cc-head { cursor: default; }
.ext-card .cc-ico { font-size: 18px; }
.ext-card .cc-caret { color: var(--c); }
.ext-card .cc-cta { pointer-events: none; }
.cc-lesson.locked, .lesson-item.locked { color: var(--muted); }
.cc-lesson.locked .s, .lesson-item.locked .l-state { color: var(--cyan); }
.cc-lesson.locked:hover, .lesson-item.locked:hover { filter: brightness(1.12); }

.ai-access-state {
  width: min(720px, calc(100% - 32px)); margin: clamp(24px, 8vh, 80px) auto;
  padding: clamp(22px, 4vw, 38px); border: 1px solid var(--line); border-radius: 20px;
  background: linear-gradient(135deg, var(--panel), rgba(139,92,246,.08));
  box-shadow: var(--shadow, 0 18px 48px rgba(0,0,0,.2)); text-align: center;
}
.ai-pass-notice { position: sticky; top: 10px; z-index: 20; width: min(760px, calc(100% - 24px));
  margin: 10px auto; padding: 12px 16px; border: 1px solid #d69a32; border-radius: 12px;
  background: #fff4d8; color: #4a3210; font-size: 13px; line-height: 1.55; box-shadow: 0 6px 20px rgba(0,0,0,.14); }
.ai-access-mark { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 16px; background: rgba(139,92,246,.14); color: var(--cyan); font-size: 24px; }
.ai-access-state[role="status"] .ai-access-mark { border: 3px solid rgba(139,92,246,.2); border-top-color: var(--cyan); border-radius: 50%; font-size: 0; animation: ai-access-spin .8s linear infinite; }
@keyframes ai-access-spin { to { transform: rotate(360deg); } }
.ai-access-eyebrow { margin: 0 0 8px; color: var(--cyan); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.ai-access-state h2 { margin: 0 0 10px; font-size: clamp(20px, 3vw, 27px); line-height: 1.35; color: var(--text); }
.ai-access-state p:not(.ai-access-eyebrow) { max-width: 520px; margin: 0 auto; color: var(--muted); font-size: 14px; line-height: 1.75; }
.ai-access-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.ai-access-actions a { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 10px 18px;
  border: 1px solid var(--line); border-radius: 12px; color: var(--text); font-weight: 750; text-decoration: none; }
.ai-access-actions .ai-access-primary { border-color: transparent; background: linear-gradient(100deg,#ffc65c,#ff9db0); color: #2b1c05; }
.ai-access-actions a:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,.15); }

@media (max-width: 900px) { .course-grid { grid-template-columns: 1fr; } }
/* 矮屏进一步压缩，保证折叠态仍是一屏 */
@media (max-height: 720px) {
  .home-wrap { padding: 12px 18px 14px; gap: 10px; }
  .home-head h1 { font-size: 22px; }
  .cc-head { padding: 11px 12px; }
  .cc-ico { width: 34px; height: 34px; }
  .cc-lessons { max-height: 132px; }
}
