/* ==========================================================================
   uibe-course-planner · 工具型工作台
   设计取向：中性灰 + 单一强调色，信息密度优先，动效克制。
   规则（全站一致，不混用）：
     · 圆角：控件 10px，标签 6px，面板 14px
     · 颜色：中性 zinc 系 + 强调色 teal-700；语义色仅用于状态，不做装饰
     · 动效：只用 opacity / transform，200ms 以内，遵循 prefers-reduced-motion
   ========================================================================== */

:root {
  color-scheme: light dark;

  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f4f4f5;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #8b8b93;

  --accent: #0f766e;
  --accent-on: #ffffff;
  --accent-ink: #115e59;
  --accent-soft: #ccfbf1;
  --accent-line: #99f6e4;

  --fixed: #27272a;
  --fixed-on: #ffffff;
  --fixed-soft: #f4f4f5;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --alt: #b45309;
  --alt-soft: #fffbeb;
  --alt-line: #fde68a;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --neon: #facc15;
  --neon-soft: #fef9c3;
  --neon-line: #eab308;
  --neon-ink: #422006;

  --r-tag: 6px;
  --r: 10px;
  --r-panel: 14px;

  --shadow-panel: 0 1px 2px rgba(24, 24, 27, .04), 0 8px 24px rgba(24, 24, 27, .05);

  --font: "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, -apple-system,
          "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

:root[data-theme="dark"] {
    --bg: #0e0e11;
    --surface: #17171b;
    --surface-2: #1c1c21;
    --surface-3: #232329;
    --line: #2a2a31;
    --line-strong: #3a3a43;
    --text: #f4f4f5;
    --text-2: #b4b4bd;
    --text-3: #83838f;

    --accent: #2dd4bf;
    --accent-on: #062522;
    --accent-ink: #5eead4;
    --accent-soft: #113c38;
    --accent-line: #1c5f58;

    --fixed: #e4e4e7;
    --fixed-on: #18181b;
    --fixed-soft: #232329;
    --alt: #fbbf24;
    --alt-soft: #2e2410;
    --alt-line: #5a4415;
    --warning: #fbbf24;
    --warning-soft: #2e2410;
    --danger: #f87171;
    --danger-soft: #2e1414;
    --neon: #fde047;
    --neon-soft: #3a3410;
    --neon-line: #a16207;
    --neon-ink: #fef9c3;

    --shadow-panel: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e11;
    --surface: #17171b;
    --surface-2: #1c1c21;
    --surface-3: #232329;
    --line: #2a2a31;
    --line-strong: #3a3a43;
    --text: #f4f4f5;
    --text-2: #b4b4bd;
    --text-3: #83838f;

    --accent: #2dd4bf;
    --accent-on: #062522;
    --accent-ink: #5eead4;
    --accent-soft: #113c38;
    --accent-line: #1c5f58;

    --fixed: #e4e4e7;
    --fixed-on: #18181b;
    --fixed-soft: #232329;
    --alt: #fbbf24;
    --alt-soft: #2e2410;
    --alt-line: #5a4415;
    --warning: #fbbf24;
    --warning-soft: #2e2410;
    --danger: #f87171;
    --danger-soft: #2e1414;
    --neon: #fde047;
    --neon-soft: #3a3410;
    --neon-line: #a16207;
    --neon-ink: #fef9c3;

    --shadow-panel: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

button, input, select { font: inherit; color: inherit; }

:where(button, a, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-tag);
}

::selection { background: var(--accent-soft); color: var(--text); }

/* ---------- 布局骨架 ---------- */
.app {
  height: 100dvh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand strong { font-size: 15px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand span { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stats { display: flex; gap: 14px; margin-left: auto; align-items: center; }
.stat { display: flex; align-items: baseline; gap: 5px; font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.stat b { font-size: 14px; font-weight: 650; color: var(--text); font-family: var(--mono); }
.stat.is-over b { color: var(--danger); }
.sync-status { font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); }
.sync-status[data-kind="ok"] { color: var(--accent-ink); border-color: var(--accent-line, var(--line)); }
.sync-status[data-kind="warn"] { color: var(--danger); border-color: var(--danger); }

/* 排课模式开关：手动 / AI */
.mode-switch {
  display: inline-flex;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.mode-switch button {
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease;
}
.mode-switch button + button { border-left: 1px solid var(--line); }
.mode-switch button:hover { background: var(--surface-3); color: var(--text); }
.mode-switch button.on {
  background: var(--accent);
  color: var(--accent-on);
  font-weight: 600;
}

.major-select {
  max-width: 260px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r);
  padding: 6px 9px;
  font-size: 12.5px;
  cursor: pointer;
}
.major-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.topbar-actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r);
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: transform .12s ease, background .16s ease, border-color .16s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-on); }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }

.workspace {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) clamp(480px, 48vw, 820px);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.pane { min-height: 0; min-width: 0; overflow: auto; }
.pane.rail { background: var(--surface); border-right: 1px solid var(--line); padding: 12px 10px; }
.pane.list { padding: 12px 14px 18px; container-type: inline-size; }
.pane.side { background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; }

/* 排课助手：开了对话面板时，工作区多留一列给它 */
.workspace.chat-open { grid-template-columns: 170px minmax(0, 1fr) clamp(420px, 40vw, 720px) 380px; }
.pane.chat { background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.pane.chat[hidden] { display: none; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat-head strong { font-size: 13px; }
.chat-code { margin-left: auto; font: 600 11px var(--mono); letter-spacing: .08em; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text-2); cursor: pointer; }
.chat-code:hover { border-color: var(--accent); color: var(--accent-ink); }
.chat-body { flex: 1; min-height: 0; }
.chat-body iframe { border: 0; width: 100%; height: 100%; display: block; }
.chat-hint { margin: 0; padding: 8px 12px; font-size: 11.5px; color: var(--text-3); border-top: 1px solid var(--line); }
@media (max-width: 1400px) {
  .workspace.chat-open { grid-template-columns: 150px minmax(0, 1fr) clamp(380px, 34vw, 560px) 340px; }
}
@media (max-width: 1100px) {
  .workspace.chat-open { grid-template-columns: minmax(0, 1fr) clamp(360px, 40vw, 520px); }
  .workspace.chat-open .pane.rail { display: none; }
}
@media (max-width: 820px) {
  .workspace.chat-open { grid-template-columns: minmax(0, 1fr); }
  .workspace.chat-open .pane.chat { position: fixed; inset: auto 0 0 0; height: 72vh; z-index: 60; border-top: 1px solid var(--line); box-shadow: 0 -12px 32px rgba(0,0,0,.18); }
}

/* ---------- AI 排课模式：课表左上 / 备选池左下 / 对话常驻右侧 ---------- */
.workspace[data-mode="ai"] {
  grid-template-columns: minmax(0, 1fr) clamp(360px, 34vw, 520px);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "side chat" "list chat";
}
.workspace[data-mode="ai"] .pane.rail { display: none; }
.workspace[data-mode="ai"] .pane.side { grid-area: side; border-left: 0; border-bottom: 1px solid var(--line); }
.workspace[data-mode="ai"] .pane.list { grid-area: list; }
.workspace[data-mode="ai"] .pane.chat { grid-area: chat; display: flex; }
.workspace[data-mode="ai"] .viewswitch { display: none; }
/* AI 模式是只读的备选池视图：藏掉筛选栏，避免搜索把 view:'pool' 写回存档 */
.workspace[data-mode="ai"] .searchbar { display: none; }

/* 窄屏 AI 模式改用底部标签（课表 / 备选 / 对话），规则见文件末尾。 */

/* ---------- 模块轨 ---------- */
.rail h2, .side h2 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-3);
  margin-bottom: 10px;
}

.mod {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--r);
  padding: 8px 10px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.mod + .mod { margin-top: 2px; }
.mod:hover { background: var(--surface-3); }
.mod.on { background: var(--accent-soft); border-color: var(--accent-line); }
.mod .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.mod .name { font-size: 13px; color: var(--text); }
.mod.on .name { color: var(--accent-ink); font-weight: 600; }
.mod .gap { font-size: 11px; color: var(--text-3); font-family: var(--mono); white-space: nowrap; }
.mod.on .gap { color: var(--accent-ink); }
.mod .bar { height: 3px; border-radius: 2px; background: var(--surface-3); margin-top: 7px; overflow: hidden; }
.mod .bar i { display: block; height: 100%; background: var(--accent); }
.mod .bar i.short { background: var(--danger); }
.mod .bar i.mid { background: var(--alt); }

.rail-note { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--text-3); line-height: 1.7; }
.rail-note b { color: var(--text-2); font-weight: 600; }

/* ---------- 选课阶段 ---------- */
.stagebar { display: flex; gap: 4px; margin-bottom: 8px; overflow: auto; }
.stagebar button {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text-3); border-radius: 999px; padding: 4px 10px;
  font-size: 11.5px; white-space: nowrap; cursor: default;
}
.stagebar button.on {
  background: var(--accent); border-color: var(--accent); color: var(--accent-on); font-weight: 650;
}
.stagebar button:disabled { opacity: .55; }

/* ---------- 新手引导（独立页，旧弹窗样式已下线） ---------- */
[hidden] { display: none !important; }
@media (max-width: 760px) { .stagebar { margin-bottom: 6px; } }

/* ---------- 独立新手引导页 ---------- */
.guide-app { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.onboarding { overflow: auto; padding: 22px 26px 30px; }
.onboard-panel {
  max-width: 1180px; margin: 0 auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 26px 28px;
}
.onboard-head h1 { font-size: 24px; letter-spacing: -.02em; line-height: 1.15; margin: 6px 0 8px; }
.onboard-head p { color: var(--text-2); font-size: 13px; line-height: 1.65; max-width: 68ch; }
.onboard-kicker { color: var(--accent-ink); font-size: 11.5px; font-weight: 650; letter-spacing: .06em; }
.onboard-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 26px; }
.onboard-field { display: grid; gap: 7px; font-size: 12px; color: var(--text-2); }
.onboard-note { margin-top: 18px; padding: 10px 12px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); font-size: 12px; line-height: 1.6; }
.onboard-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 12px; }
.recommend-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; margin-top: 22px; align-items: start; }
.recommend-list { display: grid; gap: 18px; }
.recommend-group h2 { font-size: 14px; margin-bottom: 9px; }
.recommend-group h2 em { color: var(--text-3); font-size: 11px; font-style: normal; margin-left: 6px; }
.recommend-course { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); }
.recommend-course header { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.recommend-course header b { font-family: var(--mono); }
.recommend-course header span { color: var(--text-3); font-size: 11.5px; }
.reason { margin-top: 7px; color: var(--accent-ink); font-size: 11.5px; line-height: 1.55; }
.course-terms { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-top: 8px; }
.term-badge {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 11px; font-weight: 650;
}
.term-note { color: var(--text-3); font-size: 11px; }
.recommend-classes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.recommend-class, .recommend-add {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
  border-radius: 7px; padding: 6px 10px; font-size: 11px; cursor: pointer;
  transition: transform .12s ease, border-color .16s ease, background .16s ease, color .16s ease;
}
.recommend-class:hover, .recommend-add:hover { border-color: var(--accent); color: var(--accent-ink); }
.recommend-class:active, .recommend-add:active { transform: scale(.98); }
.recommend-class.on, .recommend-add.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.recommend-missing, .recommend-empty { color: var(--text-3); font-size: 11.5px; line-height: 1.6; }
.recommend-group.missing h2 { color: var(--alt); }
.recommend-course.missing { border-style: dashed; background: var(--surface-3); }
.recommend-course.missing .term-badge { background: var(--alt-soft); color: var(--alt); }
.recommend-course.missing .reason { color: var(--text-2); }
.recommend-course.missing .recommend-missing {
  display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 6px;
  background: var(--alt-soft); color: var(--alt); font-size: 11px; font-weight: 600;
}
.group-note { color: var(--text-3); font-size: 11.5px; line-height: 1.55; margin: -2px 0 9px; }
.future-note { color: var(--text-3); font-size: 11.5px; line-height: 1.6; padding: 0 2px; }
.recommend-summary { position: sticky; top: 0; border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--surface-2); }
.recommend-summary h2 { font-size: 13px; }
.summary-count { margin: 8px 0 12px; font-size: 20px; font-weight: 700; font-family: var(--mono); }
.summary-list { display: grid; gap: 7px; max-height: 320px; overflow: auto; }
.summary-item { font-size: 12px; display: grid; gap: 2px; }
.summary-item span { color: var(--text-3); font-size: 10.5px; }
.summary-actions { display: grid; gap: 8px; margin-top: 16px; }
.summary-note { margin-top: 12px; color: var(--text-3); font-size: 11px; line-height: 1.55; }
@media (max-width: 980px) {
  .onboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recommend-layout { grid-template-columns: 1fr; }
  .recommend-summary { position: static; }
}
@media (max-width: 620px) {
  .onboarding { padding: 14px; }
  .onboard-panel { padding: 18px 16px; }
  .onboard-head h1 { font-size: 20px; }
  .onboard-grid { grid-template-columns: 1fr; }
}

/* ---------- 课程库 / 备选 大切换 ---------- */
.viewswitch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 3px; margin-bottom: 9px;
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: 12px;
}
.viewswitch button {
  border: 0; border-radius: 9px; padding: 8px 10px;
  background: transparent; color: var(--text-2);
  font-size: 13.5px; font-weight: 550; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}
.viewswitch button:hover { color: var(--text); background: var(--surface-2); }
.viewswitch button.on {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 2px rgba(24, 24, 27, .08), 0 0 0 1px var(--line);
}
.viewswitch button b {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  color: var(--accent-ink); background: var(--accent-soft);
  border-radius: 999px; padding: 0 7px; line-height: 18px;
}

/* ---------- 搜索区 ---------- */
.list-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; flex-wrap: wrap; }
.list-head h1 { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
.list-head .meta { font-size: 11.5px; color: var(--text-3); }

.searchbar { display: grid; grid-template-columns: minmax(0, 1fr) 140px 130px; gap: 7px; margin-bottom: 9px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.search-field { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r); box-shadow: var(--shadow-panel);
  max-height: 320px; overflow: auto; padding: 5px;
}
.suggest-group { padding: 5px 7px 3px; font-size: 10.5px; color: var(--text-3); letter-spacing: .04em; }
.suggest-item {
  display: flex; width: 100%; align-items: baseline; gap: 8px;
  padding: 7px 8px; border: 0; border-radius: 7px; background: transparent;
  text-align: left; font-size: 12.5px; color: var(--text); cursor: pointer;
}
.suggest-item:hover, .suggest-item.on { background: var(--surface-3); }
.suggest-item b { font-family: var(--mono); font-size: 11px; color: var(--text-2); font-weight: 500; }
.suggest-item small { margin-left: auto; color: var(--text-3); font-size: 10.5px; }
.teacher-filter { display: flex; flex-wrap: wrap; gap: 5px; }
.teacher-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-ink);
  border-radius: 999px; padding: 2px 9px; font-size: 11px; cursor: pointer;
}
.teacher-chip b { font-weight: 650; }
.teacher-chip i { font-style: normal; font-size: 13px; line-height: 1; }
.field label { font-size: 11.5px; color: var(--text-2); font-weight: 500; }
.input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { cursor: pointer; }

/* ---------- 课程表 ---------- */
.courses {
  width: 100%; table-layout: fixed; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden;
}
.courses thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-3);
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.courses thead th:nth-child(1) { width: 29%; }
.courses thead th:nth-child(2) { width: 12%; }
.courses thead th:nth-child(3) { width: 8%; }
.courses thead th:nth-child(4) { width: 25%; }
.courses thead th:nth-child(5) { width: 11%; }
.courses thead th:nth-child(6) { width: 15%; }
.courses tbody td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.courses tbody tr:last-child td { border-bottom: 0; }
.courses tbody tr:hover td { background: var(--surface-2); }
.courses tbody tr.group-course { cursor: pointer; }
.courses tbody tr.group-course td:nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.courses tbody tr.group-course .cname { font-size: 14px; }
.courses tbody tr.group-course:hover td { background: var(--surface-2); }
.courses tbody tr.group-course td:first-child,
.courses tbody tr[data-key] td:first-child { transition: box-shadow .16s ease; }
.courses tbody tr.group-course:hover td:first-child,
.courses tbody tr[data-key]:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--neon-line);
}
.back-group { margin-bottom: 8px; }
.courses tbody tr.group-row.pool-kind td {
  background: var(--surface-3);
  font-weight: 700;
  color: var(--text);
  border-top: 2px solid var(--line-strong);
}
.courses tbody tr.added td { background: var(--accent-soft); }
.courses tbody tr.added:hover td { background: var(--accent-soft); }
.courses tbody tr.focus td {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.courses tbody tr.group-row td {
  padding: 8px 12px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px; color: var(--text-2); font-weight: 600;
}
.courses tbody tr.group-row span { letter-spacing: .02em; }
.courses tbody tr.group-row em {
  float: right; font-style: normal; font-weight: 400;
  color: var(--text-3); font-family: var(--mono); font-size: 11px;
}
.only-card { display: none; }
.addbtn.remove { border-color: var(--line-strong); color: var(--text-3); }
.addbtn.remove:hover { border-color: var(--danger); color: var(--danger); }

.cname { font-size: 13.5px; font-weight: 550; overflow-wrap: anywhere; }
.cname .code { font-family: var(--mono); font-size: 12px; color: var(--text-2); margin-right: 6px; }
.cmeta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }
.tag {
  font-size: 11px; padding: 1px 7px; border-radius: var(--r-tag);
  background: var(--surface-3); color: var(--text-2);
}
.tag.plan { background: var(--accent-soft); color: var(--accent-ink); }
.tag.out { background: var(--surface-3); color: var(--text-3); }
.tag.warn { background: var(--danger-soft); color: var(--danger); }
.tag.pending { background: var(--alt-soft); color: var(--alt); }
.tag.full { background: var(--surface-3); color: var(--text-3); }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.courses tbody tr.course-row td:nth-child(4) { color: var(--text-2); }
.courses tbody tr.course-row.picked td:nth-child(1) { box-shadow: inset 3px 0 0 var(--accent); }
.courses tbody tr.section-row.picked td { background: var(--accent-soft); }
.clash {
  margin-top: 6px; font-size: 11px; color: var(--danger); line-height: 1.5;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.left { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.left.low { color: var(--danger); }
.left.mid { color: var(--alt); }
.left.ok { color: var(--accent-ink); }

.addbtn {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  border-radius: var(--r); padding: 5px 12px; font-size: 12.5px; cursor: pointer; white-space: nowrap;
  transition: transform .12s ease, background .16s ease, border-color .16s ease, color .16s ease;
}
.addbtn:hover { border-color: var(--accent); color: var(--accent-ink); transform: translateY(-1px); }
.addbtn:active { transform: translateY(1px); }
.addbtn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-on); }
.addbtn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- 状态区 ---------- */
.state { padding: 40px 16px; text-align: center; color: var(--text-3); font-size: 13px; }
.state strong { display: block; color: var(--text-2); font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.state code { font-family: var(--mono); font-size: 12px; background: var(--surface-3); padding: 1px 6px; border-radius: var(--r-tag); }

.skeleton { display: grid; gap: 10px; }
.sk-row { height: 42px; border-radius: var(--r); background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.errorbox { border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger); border-radius: var(--r); padding: 14px 16px; font-size: 13px; }
.errorbox strong { display: block; margin-bottom: 4px; }
.errorbox p { color: var(--text-2); margin-bottom: 10px; }

/* ---------- 右侧面板：只放课表，常驻可见 ---------- */
.side-body { padding: 8px 10px 12px; overflow: auto; flex: 1; min-height: 0; }

/* 旧表格版课表（.timetable/.tcell）已废弃并移除 */

/* ---------- 课表：按大时段分格，主课大框 + 备选小方框 ---------- */
:root { --row: 36px; }

.unscheduled-tray {
  margin: 2px 0 12px; padding: 10px; border: 1px dashed var(--line-strong); border-radius: 9px;
  background: var(--surface-2);
}
.tray-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.tray-head b { font-size: 12px; }
.tray-head span { color: var(--text-3); font-size: 10.5px; }
.tray-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tray-course {
  display: inline-grid; grid-template-columns: auto minmax(0, 1fr); align-items: center;
  gap: 2px 6px; max-width: 100%; text-align: left;
  padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: transform .12s ease, border-color .16s ease, box-shadow .16s ease;
}
.tray-course:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 3px 10px rgba(0,0,0,.08); }
.tray-course .tc-code { font-family: var(--mono); font-size: 10px; color: var(--text-3); }
.tray-course .tc-name { font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray-course small { grid-column: 1 / -1; color: var(--alt); font-size: 10px; }

.tt-heads { display: grid; grid-template-columns: 64px repeat(7, minmax(0, 1fr)); gap: 4px; }
.tt-h {
  text-align: center; font-size: 11px; font-weight: 600; color: var(--text-3);
  padding: 3px 0;
}
.tt-corner { font-weight: 400; }

.tt-body {
  display: grid; grid-template-columns: 64px repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 5px;
}
.tt-gutter { position: relative; }
.tt-slot {
  position: absolute; left: 0; right: 0;
  border-top: 1px solid var(--line);
  font-size: 10px; color: var(--text-3); line-height: 1.35; text-align: right;
  padding: 4px 5px 0 0; display: flex; flex-direction: column; align-items: flex-end;
}
.tt-slot:first-child { border-top: 0; }
.tt-slot b { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.tt-slot span { font-size: 9.5px; white-space: nowrap; }

.tt-col {
  position: relative; background: var(--surface-2); border-radius: 8px; overflow: hidden;
  transition: box-shadow .16s ease, background .16s ease;
}
.tt-col.hot {
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
/* 大时段之间的分隔线跟着实际区域高度走，不再用固定 --row 的重复渐变 */
.tt-cell { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.tt-cell:first-child { border-top: 0; }

.tt-blk {
  position: absolute; left: 2px; right: 2px; border-radius: 5px; padding: 3px 5px; overflow: hidden;
  font-size: 10px; line-height: 1.25; cursor: pointer; z-index: 2;
  transition: transform .12s ease, box-shadow .16s ease;
}
.tt-blk:hover {
  transform: translateY(-2px) scale(1.012);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .2), 0 0 0 1px var(--neon);
  z-index: 4;
}
.tt-blk.fixed { background: var(--fixed); color: var(--fixed-on); }
.tt-blk.chosen { background: var(--accent); color: var(--accent-on); }
.tt-blk b { display: block; font-size: 10.5px; font-weight: 700; }
.tt-blk span { display: block; font-size: 9.5px; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-blk em { display: block; font-style: normal; font-size: 9px; opacity: .72; }
.tt-blk.conflict {
  outline: 2px solid var(--danger); outline-offset: -2px;
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.tt-blk.hovered {
  outline: 2px solid var(--accent); outline-offset: -2px;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 固定课右上角的取消按钮 */
.fixed-cancel {
  position: absolute; top: 0; right: 0; z-index: 5;
  width: 24px; height: 24px; padding: 0; line-height: 1;
  border: 0; border-radius: 4px; cursor: pointer;
  background: rgba(128, 128, 128, .18); color: inherit; font-size: 14px;
}
.fixed-cancel:hover { background: var(--danger); color: var(--surface); }

/* 已排课右上角的整门移出按钮：hover 才出现，避免课表太乱 */
.course-cancel {
  position: absolute; top: 2px; right: 2px; z-index: 5;
  width: 24px; height: 24px; padding: 0; line-height: 1;
  border: 0; border-radius: 4px; cursor: pointer;
  background: rgba(128, 128, 128, .18); color: inherit; font-size: 14px;
  opacity: 0; transition: opacity .14s ease, background .14s ease;
}
.tt-blk:hover .course-cancel, .course-cancel:focus-visible { opacity: 1; }
.course-cancel:hover { background: var(--danger); }

/* 悬停预览的幽灵块：不拦鼠标 */
.tt-ghost {
  position: absolute; left: 2px; right: 2px; border-radius: 6px; padding: 4px 6px;
  font-size: 9.5px; line-height: 1.2; z-index: 6; cursor: pointer;
  border: 2px dashed var(--neon-line);
  background: var(--neon-soft); color: var(--neon-ink);
  box-shadow: 0 0 0 1px var(--neon-line), 0 3px 12px rgba(234, 179, 8, .18);
  animation: ghost-pop .2s cubic-bezier(.2, .85, .25, 1.2), ghost-glow .75s ease-out;
  transition: transform .14s ease, box-shadow .16s ease;
}
.tt-ghost:hover {
  transform: translateY(-2px) scale(1.012);
  box-shadow: 0 0 0 2px var(--neon), 0 6px 18px rgba(234, 179, 8, .3);
}
.tt-ghost.self {
  border-color: var(--neon-line); background: var(--neon); color: var(--neon-ink);
  box-shadow: 0 0 0 2px var(--neon), 0 0 18px rgba(250, 204, 21, .38);
}
.tt-ghost.same, .tt-ghost.other {
  border-color: var(--neon-line); background: var(--neon-soft); color: var(--neon-ink);
}
.tt-ghost.conflict {
  border-color: var(--danger); background: var(--danger-soft); color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-soft), 0 3px 12px rgba(185, 28, 28, .14);
  animation: ghost-pop .2s cubic-bezier(.2, .85, .25, 1.2), conflict-flash .9s ease-out;
}
.tt-ghost { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
.tt-ghost b { display: block; font-size: 10px; font-weight: 700; }
.tt-ghost span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-ghost .ghost-left { min-width: 0; }
.tt-ghost .ghost-teacher { font-size: 9px; opacity: .88; }
.tt-ghost .ghost-right {
  align-self: center; text-align: right; padding-left: 3px;
  border-left: 1px solid currentColor; font-size: 8px; line-height: 1.25;
}
.tt-ghost .ghost-right strong { display: block; font-size: 8.5px; }
.tt-ghost .ghost-right small { display: block; max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .9; }
.tt-ghost .ghost-right em { display: block; font-style: normal; font-weight: 700; margin-top: 1px; }
/* 被挤下来的教学班：灰色备选小条，点一下换回主课 */
.tt-chip {
  position: absolute; left: 2px; right: 2px; height: 24px;
  display: flex; align-items: center; gap: 4px; padding: 0 6px;
  border-radius: 4px; border: 1px dashed var(--text-3); background: var(--surface-3);
  color: var(--text-2); font-size: 10px; cursor: pointer; overflow: hidden; z-index: 3;
  transition: transform .14s ease, border-color .16s ease, box-shadow .16s ease;
}
.tt-chip.backup { right: 28px; border-style: dashed; background: var(--surface-3); }
.tt-chip.conflict { border-color: var(--danger); color: var(--danger); }
.tt-chip:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 3px 10px rgba(0,0,0,.12); }
.tt-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); flex: none; }
.tt-chip .chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.tt-chip small { margin-left: auto; font-size: 8.5px; color: var(--text-3); flex: none; }
.chip-remove {
  position: absolute; right: 2px; z-index: 4; width: 24px; height: 24px;
  padding: 0; border: 1px dashed var(--text-3); border-radius: 4px;
  background: var(--surface-3); color: var(--text-2); cursor: pointer;
  font-size: 14px; line-height: 1; opacity: .72;
  transition: opacity .14s ease, background .14s ease, color .14s ease;
}
.chip-remove:hover, .chip-remove:focus-visible {
  opacity: 1; background: var(--danger); border-color: var(--danger); color: var(--surface);
}
.clear-preview { margin: 0 0 8px; font-size: 11px; padding: 4px 8px; }

.restore-fixed { margin-top: 10px; }

/* ---------- 响应式：课表优先常驻 ---------- */
.mobilebar { display: none; }

@media (max-width: 1400px) {
  .workspace { grid-template-columns: 160px minmax(0, 1fr) clamp(460px, 48vw, 760px); }
}

@media (max-width: 1100px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand span { display: none; }
  .major-select { max-width: 200px; }
  .stats { gap: 10px; }
  .stat { font-size: 10.5px; }
  .btn { padding: 5px 9px; font-size: 12px; }
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 150px minmax(0, 1fr) clamp(440px, 48vw, 620px); }
  .tt-heads, .tt-body { grid-template-columns: 58px repeat(7, minmax(0, 1fr)); gap: 3px; }
  .viewswitch button { padding: 9px 8px; font-size: 12.5px; }
  .addbtn { padding: 5px 8px; font-size: 12px; }
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 140px minmax(0, 1fr) clamp(420px, 48vw, 560px); }
  .searchbar { grid-template-columns: minmax(0, 1fr) 120px 110px; }
  .tt-heads, .tt-body { grid-template-columns: 48px repeat(7, minmax(0, 1fr)); gap: 2px; }
  .tt-slot span { display: none; }
}

/* 窄屏：模块轨变成抽屉，课表仍常驻在右侧 */
@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 420px; }
  .pane.rail {
    display: none;
    position: fixed; top: 0; bottom: 0; left: 0;
    width: min(280px, 86vw);
    z-index: 45;
    border-right: 1px solid var(--line);
    box-shadow: 12px 0 32px rgba(0, 0, 0, .14);
  }
  .workspace[data-view="modules"] .pane.rail { display: block; }
  .mobilebar { display: grid; grid-template-columns: repeat(2, 1fr); }
  .mobilebar button[data-view="side"] { display: none; }
}

/* 列表自身变窄时先收搜索区，再切卡片；右栏打开时整页宽度没变，不能用 @media 判断 */
@container (max-width: 860px) {
  .searchbar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .searchbar .field:nth-child(3) { grid-column: 1 / -1; }
}
@container (max-width: 560px) {
  .searchbar { grid-template-columns: minmax(0, 1fr); }
  .searchbar .field:nth-child(3) { grid-column: auto; }
  .list-head { gap: 6px; }
}

/* 列表自身变窄时切成卡片，不跟整页宽度绑死 */
@container (max-width: 620px) {
  .courses thead { display: none; }
  .courses, .courses tbody, .courses tr, .courses td { display: block; width: 100%; }
  .courses tbody tr {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name action"
      "teacher action"
      "time action"
      "meta action"
      "stats action";
    column-gap: 10px;
  }
  .courses tbody tr.group-row { display: block; padding: 0; }
  .courses tbody tr.group-row td { padding: 8px 14px; }
  .courses tbody tr.group-course {
    display: block; position: relative; padding: 10px 14px 9px;
  }
  .courses tbody tr.group-course td { display: inline-block; width: auto; padding: 1px 10px 1px 0; border: 0; }
  .courses tbody tr.group-course td:nth-child(1) { display: block; padding-right: 92px; }
  .courses tbody tr.group-course td:nth-child(2) { color: var(--text-2); }
  .courses tbody tr.group-course td:nth-child(3) { display: none; }
  .courses tbody tr.group-course td:nth-child(4) { color: var(--text-2); }
  .courses tbody tr.group-course td:nth-child(5) { color: var(--text-2); }
  .courses tbody tr.group-course td:nth-child(6) { position: absolute; top: 10px; right: 12px; padding: 0; }
  .courses tbody tr.group-course td:nth-child(2)::before { content: "教师 "; color: var(--text-3); }
  .courses tbody tr.group-course td:nth-child(5)::before { content: "余量 "; color: var(--text-3); }
  .courses tbody tr.group-course .only-card { display: inline-block; }
  .courses tbody tr:last-child { border-bottom: 0; }
  .courses tbody td { border: 0; padding: 1px 0; }
  .courses tbody td:nth-child(1) { grid-area: name; }
  .courses tbody td:nth-child(2) { grid-area: teacher; }
  .courses tbody td:nth-child(3) { grid-area: stats; }
  .courses tbody td:nth-child(4) { grid-area: time; }
  .courses tbody td:nth-child(5) { grid-area: meta; }
  .courses tbody td:nth-child(6) { grid-area: action; align-self: start; }
  .courses tbody td:nth-child(2)::before { content: "教师 "; color: var(--text-3); }
  .courses tbody td:nth-child(3)::before { content: "学分 "; color: var(--text-3); }
  .courses tbody td:nth-child(5)::before { content: "余量 "; color: var(--text-3); }
}

/* 手机：课表变成右侧抽屉，列表回到单列 */
@media (max-width: 760px) {
  .topbar { height: auto; padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .brand span { display: none; }
  .stats { gap: 12px; width: 100%; order: 3; margin-left: 0; }
  .topbar-actions { margin-left: auto; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .searchbar { grid-template-columns: minmax(0, 1fr); }
  .pane.side {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 100%;
    z-index: 40;
    border-left: 1px solid var(--line);
    box-shadow: -12px 0 32px rgba(0, 0, 0, .14);
  }
  .workspace[data-view="side"] .pane.side { display: flex; }
  /* 7 天课表保持可读宽度；窄屏在课表抽屉内部横向滚动，不压缩课程代码。 */
  .pane.side .tt { min-width: 640px; }
  .pane.side .side-body { padding-bottom: 64px; }
  .mobilebar { display: grid; grid-template-columns: repeat(3, 1fr); }
  .mobilebar button[data-view="side"] { display: block; }

  .courses thead { display: none; }
  .courses, .courses tbody, .courses tr, .courses td { display: block; width: 100%; }
  .courses tbody tr {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name action"
      "teacher action"
      "time action"
      "meta action"
      "stats action";
    column-gap: 10px;
  }
  .courses tbody tr.group-row { display: block; padding: 0; }
  .courses tbody tr.group-row td { padding: 8px 14px; }
  .courses tbody tr.group-course {
    display: block; position: relative; padding: 10px 14px 9px;
  }
  .courses tbody tr.group-course td { display: inline-block; width: auto; padding: 1px 10px 1px 0; border: 0; }
  .courses tbody tr.group-course td:nth-child(1) { display: block; padding-right: 92px; }
  .courses tbody tr.group-course td:nth-child(2) { color: var(--text-2); }
  .courses tbody tr.group-course td:nth-child(3) { display: none; }
  .courses tbody tr.group-course td:nth-child(4) { color: var(--text-2); }
  .courses tbody tr.group-course td:nth-child(5) { color: var(--text-2); }
  .courses tbody tr.group-course td:nth-child(6) { position: absolute; top: 10px; right: 12px; padding: 0; }
  .courses tbody tr.group-course td:nth-child(2)::before { content: "教师 "; color: var(--text-3); }
  .courses tbody tr.group-course td:nth-child(5)::before { content: "余量 "; color: var(--text-3); }
  .courses tbody tr.group-course .only-card { display: inline-block; }
  .courses tbody tr:last-child { border-bottom: 0; }
  .courses tbody td { border: 0; padding: 1px 0; }
  .courses tbody td:nth-child(1) { grid-area: name; }
  .courses tbody td:nth-child(2) { grid-area: teacher; }
  .courses tbody td:nth-child(3) { grid-area: stats; }
  .courses tbody td:nth-child(4) { grid-area: time; }
  .courses tbody td:nth-child(5) { grid-area: meta; }
  .courses tbody td:nth-child(6) { grid-area: action; align-self: start; }
  .courses tbody td:nth-child(3)::before { content: "学分 "; color: var(--text-3); }
  .courses tbody td:nth-child(5)::before { content: "余量 "; color: var(--text-3); }
}

.mobilebar {
  grid-template-columns: repeat(3, 1fr);
  position: sticky;
  bottom: 0;
  z-index: 50;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.mobilebar button {
  padding: 12px 4px;
  background: transparent;
  border: 0;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
}
.mobilebar button.on { color: var(--accent-ink); font-weight: 600; }

/* ---------- AI 模式手机标签：课表 / 备选 / 对话，一次只显示一个面板 ---------- */
/* 手动模式保留「模块 / 课程 / 课表」，AI 模式换成三个面板标签。 */
.mobilebar button[data-aitab] { display: none; }
body[data-mode="ai"] .mobilebar { grid-template-columns: repeat(3, 1fr); }
body[data-mode="ai"] .mobilebar button[data-view] { display: none; }
body[data-mode="ai"] .mobilebar button[data-aitab] { display: block; }

/* 与 mobilebar 出现的最宽断点一致（900px）；≤820 自然包含在内。 */
@media (max-width: 900px) {
  /* 单列单行网格：三个面板叠在同一格，用 display 只露出当前标签对应的那个。 */
  #workspace[data-mode="ai"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "main";
  }
  #workspace[data-mode="ai"] .pane.side,
  #workspace[data-mode="ai"] .pane.list,
  #workspace[data-mode="ai"] .pane.chat {
    grid-area: main;
    /* 取消手动模式的抽屉/浮层定位，对话不再以 72vh 盖住底部导航。 */
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    z-index: auto;
    border: 0;
    box-shadow: none;
    display: none;
  }
  #workspace[data-mode="ai"][data-aitab="schedule"] .pane.side { display: flex; }
  #workspace[data-mode="ai"][data-aitab="pool"] .pane.list { display: block; }
  #workspace[data-mode="ai"][data-aitab="chat"] .pane.chat { display: flex; }
}

@keyframes ghost-pop {
  from { opacity: 0; transform: translateY(7px) scale(.96); }
  65% { opacity: 1; transform: translateY(-2px) scale(1.015); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes conflict-flash {
  0%, 32% { border-color: var(--neon-line); background: var(--neon); color: var(--neon-ink); }
  70%, 100% { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
}
@keyframes ghost-glow {
  0% { filter: brightness(1); }
  35% { filter: brightness(1.22); }
  100% { filter: brightness(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- 备选池折叠分组 ---------- */
.courses.pool-accordion thead { display: none; }
.courses.pool-accordion > tbody { display: block; }
.pool-group { display: block; border-bottom: 1px solid var(--line); }
.pool-group > summary {
  display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 9px 14px;
  cursor: pointer; list-style: none; color: var(--text); font-weight: 650;
}
.pool-group > summary::-webkit-details-marker { display: none; }
.pool-group > summary .chevron {
  width: 8px; height: 8px; flex: none; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .16s ease;
}
.pool-group[open] > summary .chevron { transform: rotate(45deg); }
.pool-group > summary em { margin-left: auto; font-size: 11px; color: var(--text-3); font-style: normal; }
.pool-group.pool-kind > summary { background: var(--surface-2); font-size: 12px; }
.pool-group-body { display: block; }
.pool-group-body .pool-group { margin-left: 10px; }
.pool-group-body tr.course-row td { background: var(--surface); }

/* ---------- 右下角 warning 面板 ---------- */
.warning-panel {
  position: fixed; right: 18px; bottom: 18px; z-index: 30;
  width: min(440px, calc(100vw - 36px)); max-height: min(38vh, 360px);
  overflow: auto; border: 1px solid var(--warning); border-radius: 10px;
  background: var(--warning-soft); color: var(--text); box-shadow: var(--shadow-panel);
}
.warning-panel > summary {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer;
  list-style: none; color: var(--warning); font-size: 12px;
}
.warning-panel > summary::-webkit-details-marker { display: none; }
.warning-panel > summary b { font-weight: 700; }
.warning-panel > summary em { margin-left: auto; font-style: normal; color: var(--text-2); }
.warning-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.warning-body { padding: 0 12px 10px; }
.warning-item { padding: 7px 0; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.55; }
.visually-hidden {
  position: absolute !important; clip-path: inset(50%) !important; overflow: hidden !important;
  width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important; border: 0 !important;
  white-space: nowrap !important;
}

/* ---------- 悬停联动高亮 ---------- */
#listArea tr.hover-source td { background: var(--accent-soft) !important; box-shadow: inset 0 0 0 9999px rgb(255 255 0 / .06); }
.tt-blk.hover-related { outline: 2px solid var(--accent); outline-offset: -2px; }

@media (max-width: 760px) {
  .warning-panel { right: 8px; bottom: 64px; width: calc(100vw - 16px); }
}
.warning-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.warning-action { padding: 3px 8px; font-size: 11px; }
.addbtn.schedule-course.done { opacity: .75; cursor: default; border-style: dashed; }

/* ---------- 引导页：全选本学期必修 ---------- */
.select-all-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px;
  margin: 0 0 10px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.select-all {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 4px; cursor: pointer; font-weight: 600;
}
.select-all input {
  accent-color: var(--accent);
  inline-size: 1.2em; aspect-ratio: 1; margin: 0; cursor: pointer;
}
.select-all-note { font-size: 11.5px; color: var(--text-3); }

/* ---------- 分级提醒 ---------- */
.warning-level {
  display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 700; vertical-align: 1px;
}
.warning-level.sev-error { background: var(--danger-soft); color: var(--danger); }
.warning-level.sev-warn { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning); }
.warning-level.sev-info { background: var(--accent-soft); color: var(--accent-ink); }
.warning-panel.sev-error { border-color: var(--danger); background: var(--danger-soft); }
.warning-panel.sev-error > summary { color: var(--danger); }
.warning-item p { display: inline; margin: 0; }
.warning-item.sev-info { color: var(--text-2); }

/* ---------- 大类分流提示 ---------- */
.division-note {
  margin-top: 10px; padding: 10px 12px; border-radius: 8px;
  font-size: 12px; line-height: 1.6;
  border: 1px solid var(--warning); background: var(--warning-soft); color: var(--warning);
}
.division-note[data-level="pending"] {
  border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-ink);
}
