/* ============================================================
   WorkBuddy v3.0 · 基础样式与组件
   ============================================================ */

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

html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--f-base);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--sage-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select, button { font-family: inherit; font-size: var(--f-base); color: var(--ink); }
::selection { background: var(--matcha); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--matcha); border-radius: var(--r-pill); border: 2px solid var(--cream); }
::-webkit-scrollbar-thumb:hover { background: var(--sage); }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 应用骨架 ============ */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ---- 侧边栏 ---- */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--matcha-soft), var(--cream-2));
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  transition: width .22s ease;
  flex-shrink: 0;
}
.app.collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-5); border-bottom: 1px solid var(--line);
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--sage), var(--sage-deep));
  display: grid; place-items: center; color: #fff; font-size: 18px;
  box-shadow: var(--shadow-sm);
}
.brand .name { font-weight: 700; font-size: var(--f-md); color: var(--sage-deeper); white-space: nowrap; }
.brand .sub { font-size: 10px; color: var(--ink-faint); white-space: nowrap; }
.app.collapsed .brand .name, .app.collapsed .brand .sub { display: none; }

.nav { flex: 1; overflow-y: auto; padding: var(--s-4) var(--s-3); }
.nav-group-label {
  font-size: var(--f-xs); color: var(--ink-faint); padding: var(--s-4) var(--s-4) var(--s-2);
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.app.collapsed .nav-group-label { opacity: 0; height: var(--s-3); padding: 0; }
.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  color: var(--ink-soft); font-size: var(--f-base); font-weight: 500;
  margin-bottom: 2px; white-space: nowrap; transition: background .15s, color .15s;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item .ico { font-size: var(--ic-md); width: var(--ic-md); flex-shrink: 0; text-align: center; }
.nav-item:hover { background: var(--matcha-soft); color: var(--sage-deeper); text-decoration: none; }
.nav-item.active { background: var(--sage); color: #fff; box-shadow: var(--shadow-sm); }
.nav-item.active .ico { filter: drop-shadow(0 1px 1px rgba(0,0,0,.12)); }
.app.collapsed .nav-item .label { display: none; }
.app.collapsed .nav-item { justify-content: center; padding: var(--s-3) 0; }

.sidebar-foot { padding: var(--s-3); border-top: 1px solid var(--line); }
.teacher-chip {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md); background: var(--cream-2); cursor: pointer;
}
.teacher-chip:hover { background: var(--matcha-soft); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--butter), var(--sage)); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: var(--f-base);
}
.teacher-chip .meta { overflow: hidden; white-space: nowrap; }
.teacher-chip .meta .t1 { font-weight: 600; font-size: var(--f-sm); color: var(--ink); }
.teacher-chip .meta .t2 { font-size: var(--f-xs); color: var(--ink-faint); }
.app.collapsed .teacher-chip .meta { display: none; }

/* ---- 主区域 ---- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---- 顶栏 ---- */
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-6);
  background: rgba(255,253,247,.86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); z-index: 20;
}
.topbar .menu-btn {
  border: none; background: transparent; font-size: var(--ic-lg); color: var(--sage-deep);
  width: 38px; height: 38px; border-radius: var(--r-sm);
}
.topbar .menu-btn:hover { background: var(--matcha-soft); }
.week-pill {
  display: flex; align-items: center; gap: var(--s-2);
  background: var(--matcha-soft); color: var(--sage-deeper);
  padding: var(--s-2) var(--s-4); border-radius: var(--r-pill);
  font-size: var(--f-sm); font-weight: 600; white-space: nowrap;
}
.week-pill .big { font-size: var(--f-md); }
.search-box {
  flex: 1; max-width: 560px; position: relative;
}
.search-box input {
  width: 100%; height: 40px; border: 1.5px solid var(--line);
  background: var(--cream-2); border-radius: var(--r-pill);
  padding: 0 var(--s-5) 0 42px; outline: none; transition: border .15s, box-shadow .15s;
}
.search-box input:focus { border-color: var(--sage); box-shadow: 0 0 0 4px var(--matcha-soft); }
.search-box .si { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); font-size: var(--ic-md); }
.top-actions { display: flex; align-items: center; gap: var(--s-2); }
.sync-status {
  border: 1px solid var(--line); background: var(--cream-2); color: var(--ink-soft);
  border-radius: var(--r-pill); padding: 6px 10px; font-size: var(--f-xs); white-space: nowrap;
}
.sync-status:hover { background: var(--matcha-soft); color: var(--sage-deeper); }
.sync-status[data-sync-state="syncing"] { color: var(--sage-deep); }
.sync-status[data-sync-state="error"] { color: var(--danger); }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-md); border: none;
  background: var(--cream-2); color: var(--sage-deep); font-size: var(--ic-md);
  display: grid; place-items: center; transition: background .15s;
}
.icon-btn:hover { background: var(--matcha-soft); }

/* ---- 内容区 ---- */
.content { flex: 1; overflow-y: auto; padding: var(--s-8) var(--s-8) var(--s-12); }
.content-inner { max-width: var(--content-max); margin: 0 auto; }
.page-head { margin-bottom: var(--s-6); }
.page-head h1 { font-size: var(--f-xl); color: var(--sage-deeper); font-weight: 800; letter-spacing: -.01em; }
.page-head .desc { color: var(--ink-soft); font-size: var(--f-base); margin-top: var(--s-1); }
.page-head .row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }

/* ============ 卡片 ============ */
.card {
  background: var(--cream-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-xs);
}
.card.hover:hover { box-shadow: var(--shadow-sm); border-color: var(--matcha); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.card-head h3 { font-size: var(--f-md); color: var(--sage-deeper); font-weight: 700; display: flex; align-items: center; gap: var(--s-2); }
.card-head .sub { font-size: var(--f-xs); color: var(--ink-faint); }

/* ---- 首页两行两列固定高度卡片（内容超出时卡片内部滚动，不撑开页面） ---- */
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); margin-bottom: var(--s-5); align-items: stretch; }
.home-card { display: flex; flex-direction: column; height: 320px; overflow: hidden; }
.home-card .card-head { flex-shrink: 0; margin-bottom: var(--s-3); }
.home-card .hc-body { flex: 1; min-height: 0; overflow-y: auto; }
.home-card .hc-foot { flex-shrink: 0; margin-top: var(--s-3); }
@media (max-width: 720px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-card { height: auto; max-height: 360px; }
}

/* 今日课程：班级最醒目 > 时间/节次次之 > 教材章节弱化 */
.today-lesson { padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--r-md); margin-bottom: 8px; cursor: pointer; background: var(--cream); transition: border .15s; }
.today-lesson:hover { border-color: var(--matcha); }
.today-lesson .tl-cls { font-size: 17px; font-weight: 800; color: var(--sage-deeper); line-height: 1.3; }
.today-lesson .tl-time { font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.today-lesson .tl-chapter { font-size: 12px; color: var(--ink-faint); margin-top: 3px; }

/* 课表周导航 */
.week-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: var(--s-3); }
.week-nav .wk-label { font-weight: 700; color: var(--sage-deeper); font-size: var(--f-sm); }
.week-nav .btn.on { border-color: var(--sage); color: var(--sage-deeper); background: var(--matcha-soft); }
.sched .sc-cell.head small { display: block; font-size: 10px; font-weight: 500; color: var(--ink-faint); letter-spacing: 0; }

/* 题库自定义主题 chip：可删除标记 */
.chip-toggle.custom { padding-right: 6px; }
.chip-toggle .x { margin-left: 4px; color: var(--ink-faint); font-weight: 700; cursor: pointer; }
.chip-toggle .x:hover { color: var(--danger); }
.chip-toggle.topic-add { border-style: dashed; color: var(--sage-deep); }

/* ============ 第7阶段：题库富文本 / 选项 / 换课真正互换 ============ */
.q-rich { line-height: 1.7; color: var(--ink); word-break: break-word; }
.q-rich img { max-width: 100%; border-radius: 8px; margin: 4px 0; }
.q-rich table { border-collapse: collapse; margin: 8px 0; }
.q-rich td, .q-rich th { border: 1px solid var(--line); padding: 4px 10px; min-width: 40px; }
.q-rich th { background: var(--matcha-soft); font-weight: 600; }
.q-rich p { margin: 4px 0; }

.opt-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.opt-key { font-weight: 800; color: var(--sage-deeper); background: var(--matcha-soft); border-radius: 6px; padding: 2px 10px; min-width: 24px; text-align: center; }
.opt-row .input { flex: 1; min-width: 0; }
.q-opt { padding: 6px 10px; border: 1px solid var(--line-soft); border-radius: 8px; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; background: var(--cream); }
.q-opt.ok { background: var(--matcha-soft); border-color: var(--matcha); }
.q-opt .opt-key { background: var(--butter-soft); color: var(--ink); }
.q-opt .tag.green { background: #e3f1e3; color: #3f7a45; border-color: #bfe0bf; }

.rt-tools { display: flex; gap: 6px; margin: 4px 0; flex-wrap: wrap; }
/* 第8阶段B：rt-area 由「HTML 源码框」改为「所见即所得可视化编辑区」，
   因此使用正文字体（不再等宽），图片 / 表格在编辑时即可直接看到。 */
.rt-area { min-height: 80px; font-family: inherit; }

/* contenteditable 富文本编辑区 */
.rich-edit { line-height: 1.7; cursor: text; overflow-wrap: break-word; word-break: break-word; }
.rich-edit:focus { outline: none; border-color: var(--matcha); box-shadow: 0 0 0 3px var(--matcha-soft); }
.rich-edit:empty::before,
.rich-edit.is-empty::before { content: attr(data-placeholder); color: var(--ink-faint); pointer-events: none; }
.rich-edit img { max-width: 100%; max-height: 320px; border-radius: 8px; margin: 4px 0; }
.rich-edit table { border-collapse: collapse; margin: 8px 0; max-width: 100%; }
.rich-edit td, .rich-edit th { border: 1px solid var(--line); padding: 4px 10px; min-width: 40px; }
.rich-edit th { background: var(--matcha-soft); font-weight: 600; }
.rich-edit p { margin: 4px 0; }

.lesson.swap-in { border-style: dashed; border-color: var(--matcha); background: linear-gradient(180deg, var(--cream) 0%, var(--matcha-soft) 100%); position: relative; }
.lesson.swap-ex { border-style: solid; border-color: var(--butter); }
.sc-badge { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 6px; background: var(--matcha); color: var(--sage-deeper); margin-top: 4px; font-weight: 600; }
.sc-movedout { color: var(--ink-faint); font-size: 12px; padding: 10px; text-align: center; border: 1px dashed var(--line-soft); border-radius: 8px; background: transparent; }
.grid { display: grid; gap: var(--s-5); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .cols-3, .cols-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 720px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

/* 统计小卡 */
.stat {
  background: var(--cream-2); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-1);
}
.stat .label { font-size: var(--f-xs); color: var(--ink-faint); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: var(--f-xl); font-weight: 800; color: var(--sage-deeper); line-height: 1.1; }
.stat .value small { font-size: var(--f-sm); font-weight: 600; color: var(--ink-soft); }
.stat .delta { font-size: var(--f-xs); }
.stat .delta.up { color: var(--sage-deep); }
.stat .delta.down { color: var(--danger); }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 40px; padding: 0 var(--s-5); border-radius: var(--r-md); border: 1.5px solid transparent;
  font-size: var(--f-base); font-weight: 600; transition: all .15s; white-space: nowrap;
  background: var(--matcha-soft); color: var(--sage-deeper);
}
.btn:hover { background: var(--matcha); text-decoration: none; }
.btn.primary { background: var(--sage-deep); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--sage-deeper); }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn.ghost:hover { background: var(--matcha-soft); color: var(--sage-deeper); border-color: var(--matcha); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.sm { height: 32px; padding: 0 var(--s-3); font-size: var(--f-sm); border-radius: var(--r-sm); }
.btn.xs { height: 26px; padding: 0 var(--s-2); font-size: var(--f-xs); border-radius: var(--r-sm); }
.btn.block { width: 100%; }
.btn .ico { font-size: inherit; }

/* ============ 表单 ============ */
.field { margin-bottom: var(--s-4); }
.field label { display: block; font-size: var(--f-sm); font-weight: 600; color: var(--ink); margin-bottom: var(--s-2); }
.field .hint { font-size: var(--f-xs); color: var(--ink-faint); margin-top: 4px; }
.input, .textarea, .select {
  width: 100%; border: 1.5px solid var(--line); background: var(--cream-2);
  border-radius: var(--r-md); padding: var(--s-3) var(--s-4); outline: none;
  transition: border .15s, box-shadow .15s; color: var(--ink);
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--sage); box-shadow: 0 0 0 4px var(--matcha-soft); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7668' d='M6 8 0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s-4); }
@media (max-width: 720px) { .row-2, .row-3 { grid-template-columns: 1fr; } }

/* ============ 标签 / 徽章 ============ */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--matcha-soft); color: var(--sage-deeper);
  padding: 2px var(--s-3); border-radius: var(--r-pill);
  font-size: var(--f-xs); font-weight: 600; border: 1px solid var(--matcha);
}
.tag.butter { background: var(--butter-soft); color: #9a7b1e; border-color: var(--butter); }
.tag.gray { background: var(--line-soft); color: var(--ink-soft); border-color: var(--line); }
.tag.blue { background: var(--info-soft); color: #3f6f93; border-color: #cfe2f0; }
.tag.warn { background: var(--warn-soft); color: #9a6a1e; border-color: #f0d9b0; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: #f0ccbf; }
.tag.green { background: #e3f1e3; color: #3f7a45; border-color: #bfe0bf; }

/* 首页「今日提醒」列表（第5阶段B） */
.remind-list { display: flex; flex-direction: column; gap: 2px; }
.remind-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.remind-item:hover { background: var(--cream-2); }
.remind-ico { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.remind-item .link-btn { flex-shrink: 0; }
.tag.click { cursor: pointer; }
.tag.click:hover { filter: brightness(.96); }
.chip-toggle {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none;
  background: var(--cream-2); border: 1.5px solid var(--line); color: var(--ink-soft);
  padding: 4px var(--s-3); border-radius: var(--r-pill); font-size: var(--f-xs); font-weight: 600;
  transition: all .12s;
}
.chip-toggle:hover { border-color: var(--matcha); }
.chip-toggle.on { background: var(--sage); color: #fff; border-color: var(--sage); }

.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: var(--r-pill); background: var(--butter); color: #7a5f12;
  font-size: 11px; font-weight: 700;
}

/* ============ 列表 / 表格 ============ */
.list { display: flex; flex-direction: column; gap: var(--s-3); }
.list-item {
  background: var(--cream-2); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s-4); transition: all .15s;
}
.list-item.hover:hover { border-color: var(--matcha); box-shadow: var(--shadow-sm); cursor: pointer; }
.list-item .li-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); }
.list-item .li-title { font-weight: 700; color: var(--ink); font-size: var(--f-md); }
.list-item .li-meta { font-size: var(--f-xs); color: var(--ink-faint); margin-top: 2px; }
.list-item .li-body { font-size: var(--f-sm); color: var(--ink-soft); margin-top: var(--s-2); }
.list-item .li-foot { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-3); flex-wrap: wrap; }
.li-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* 题库中心：勾选框后小号题型文字（不抢视觉） */
.q-type-mini {
  flex: 0 0 auto; align-self: flex-start; margin: 3px 8px 0 2px;
  font-size: 11px; line-height: 1.4; color: var(--ink-faint);
  background: var(--cream-2); border: 1px solid var(--line-soft);
  border-radius: 6px; padding: 1px 6px; white-space: nowrap;
}

/* 题库中心最终布局：
   整个页面随 .content 正常滚动（单一滚动方向，无独立题目滚动容器、无多层 sticky）；
   顶部控制区（标题/工具栏/类别/主题）与题目列表均为普通文档流元素，自然向上滚出视野；
   仅 #qSelBar「导出选中题目」功能条在向上滚动到顶时 sticky 固定，且不透明、无空隙。 */
#qSelBar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--butter-soft); /* 不透明，题目滚到其下方时被完全遮挡，不从背后透出 */
}

.tbl { width: 100%; border-collapse: collapse; font-size: var(--f-sm); }
.tbl th { text-align: left; color: var(--ink-faint); font-weight: 600; font-size: var(--f-xs); padding: var(--s-3); border-bottom: 1.5px solid var(--line); white-space: nowrap; }
.tbl td { padding: var(--s-3); border-bottom: 1px solid var(--line-soft); color: var(--ink); vertical-align: top; }
.tbl tr:hover td { background: var(--matcha-soft); }
.tbl .num { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ============ 工具条 / 空状态 ============ */
.toolbar { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-5); flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar .filter { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.search-mini {
  position: relative; min-width: 220px;
}
.search-mini input {
  width: 100%; height: 38px; border: 1.5px solid var(--line); background: var(--cream-2);
  border-radius: var(--r-pill); padding: 0 var(--s-4) 0 38px; outline: none;
}
.search-mini input:focus { border-color: var(--sage); box-shadow: 0 0 0 4px var(--matcha-soft); }
.search-mini .si { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); }

.empty {
  text-align: center; padding: var(--s-12) var(--s-6); color: var(--ink-faint);
}
.empty .emoji { font-size: 46px; display: block; margin-bottom: var(--s-3); }
.empty .t { font-size: var(--f-md); color: var(--ink-soft); font-weight: 600; }
.empty .s { font-size: var(--f-sm); margin-top: var(--s-1); }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(62,74,60,.38); backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center; padding: var(--s-10) var(--s-4);
  z-index: 100; overflow-y: auto;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--cream-2); border-radius: var(--r-xl); width: 100%; max-width: 640px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: pop .18s ease;
  max-height: calc(100vh - 80px); display: flex; flex-direction: column;
}
.modal.wide { max-width: 880px; }
.modal.sm { max-width: 420px; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: var(--f-lg); color: var(--sage-deeper); font-weight: 800; }
.modal-head .x { border: none; background: transparent; font-size: 24px; color: var(--ink-faint); width: 34px; height: 34px; border-radius: var(--r-sm); }
.modal-head .x:hover { background: var(--matcha-soft); color: var(--ink); }
.modal-body { padding: var(--s-6); overflow-y: auto; }
.modal-foot { padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: var(--s-3); }

/* ============ Toast ============ */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: var(--s-2); align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: var(--s-3) var(--s-5); border-radius: var(--r-pill);
  font-size: var(--f-sm); box-shadow: var(--shadow-md); animation: toastin .2s ease;
}
.toast.ok { background: var(--sage-deep); }
.toast.err { background: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============ 分段标签 ============ */
.seg { display: inline-flex; background: var(--line-soft); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: var(--s-2) var(--s-4); border-radius: var(--r-sm); font-size: var(--f-sm); font-weight: 600; color: var(--ink-soft); }
.seg button.on { background: var(--cream-2); color: var(--sage-deeper); box-shadow: var(--shadow-xs); }

/* ============ 杂项 ============ */
.muted { color: var(--ink-faint); }
.divider { height: 1px; background: var(--line); margin: var(--s-5) 0; }
.flex { display: flex; } .between { justify-content: space-between; } .center { align-items: center; }
.gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); } .gap-4 { gap: var(--s-4); }
.wrap { flex-wrap: wrap; }
.stars { color: var(--butter); letter-spacing: 1px; }
.fav-on { color: var(--butter); }
.fav-off { color: var(--ink-faint); }
.link-btn { border: none; background: transparent; color: var(--sage-deep); font-weight: 600; padding: 0; font-size: inherit; }
.link-btn:hover { text-decoration: underline; }
.kbd { background: var(--line-soft); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: var(--f-xs); color: var(--ink-soft); }

/* 课表网格 */
.sched { display: grid; gap: var(--s-2); }
.sched .sched-head { display: grid; grid-template-columns: 64px repeat(7, 1fr); gap: var(--s-2); }
.sched .sched-row { display: grid; grid-template-columns: 64px repeat(7, 1fr); gap: var(--s-2); }
.sched .sc-cell {
  background: var(--cream-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  min-height: 56px; padding: 6px; font-size: var(--f-xs);
}
.sched .sc-cell.head { background: var(--matcha-soft); border-color: var(--matcha); font-weight: 700; color: var(--sage-deeper); display: grid; place-items: center; text-align: center; min-height: 40px; }
.sched .sc-cell.time { display: grid; place-items: center; font-weight: 600; color: var(--ink-soft); background: transparent; border: none; }
  .sched .lesson {
    background: linear-gradient(135deg, var(--matcha), var(--sage)); color: #fff;
    border-radius: var(--r-sm); padding: 4px 6px; margin-bottom: 4px; cursor: pointer;
    min-height: 54px;
  }
.sched .lesson .c { font-weight: 700; }
.sched .lesson .cls { opacity: .92; font-size: 11px; }
.sched .lesson.readonly { opacity: .8; cursor: default; background: linear-gradient(135deg, var(--butter), #e6c34d); }
.sched-sep { grid-column: 1 / -1; text-align: center; font-weight: 700; color: var(--sage-deeper); background: var(--matcha-soft); border: 1px solid var(--matcha); border-radius: var(--r-sm); padding: 4px 8px; font-size: var(--f-sm); letter-spacing: .12em; }

.todo-item { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3); border-radius: var(--r-md); }
.todo-item:hover { background: var(--matcha-soft); }
.todo-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--matcha); flex-shrink: 0; cursor: pointer; display: grid; place-items: center; color: #fff; font-size: 12px; margin-top: 2px; }
.todo-check.done { background: var(--sage); border-color: var(--sage); }

/* 首页快捷操作 */
.quick-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; padding: 6px 0 2px; }
.quick-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  height: 110px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-lg, 16px);
  background: var(--surface, #fff); color: var(--ink); cursor: pointer; transition: .15s ease;
}
.quick-btn:hover { border-color: var(--matcha); background: var(--matcha-soft); transform: translateY(-1px); box-shadow: var(--shadow, 0 6px 18px rgba(120,150,110,.12)); }
.quick-btn .q-ico { font-size: 32px; line-height: 1; }
.quick-btn .q-txt { font-size: 14px; font-weight: 600; }
@media (max-width: 900px) { .quick-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 560px) { .quick-grid { grid-template-columns: repeat(2, 1fr); } .quick-btn { height: 96px; } }

/* 首页今日成就 */
.ach-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 4px; }
.ach-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--cream-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.ach-label { font-size: var(--f-sm); color: var(--ink-soft); font-weight: 600; }
.ach-num { font-size: var(--f-lg); font-weight: 800; color: var(--sage-deeper); font-variant-numeric: tabular-nums; }

/* 备课资源树 */
.res-layout { display: flex; gap: var(--s-3, 16px); align-items: flex-start; }
.res-tree { width: 240px; flex-shrink: 0; padding: 14px; position: sticky; top: 12px; }
.res-tree .tree-branch { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--ink); }
.res-tree .tree-branch:hover { background: var(--matcha-soft); }
.res-tree .tree-branch .tw { color: var(--sage); width: 14px; text-align: center; }
.res-tree .tree-children { padding: 2px 0 4px 22px; }
.res-tree .tree-node { padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--ink-soft); font-size: 14px; }
.res-tree .tree-node:hover { background: var(--cream-2); color: var(--ink); }
.res-tree .tree-node.on { background: var(--matcha-soft); color: var(--sage-deeper); font-weight: 700; }
.res-tree .tree-branch.on-branch { background: var(--matcha-soft); color: var(--sage-deeper); }
@media (max-width: 760px) { .res-layout { flex-direction: column; } .res-tree { width: 100%; position: static; } }

/* 换课录入：原课程预览 / 箭头 */
.swap-preview {
  background: var(--butter-soft); border: 1px solid var(--butter); border-radius: var(--r-sm);
  padding: 8px 12px; font-size: var(--f-sm); color: var(--ink); margin: 4px 0 12px;
}
.swap-arrow { text-align: center; color: var(--sage-deep); font-weight: 700; margin: 6px 0 12px; letter-spacing: .1em; }

/* 备课网站方块卡片 */
.web-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 4px; }
.web-tile {
  background: var(--cream-2); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px; cursor: pointer; transition: .15s ease; position: relative; min-height: 96px;
}
.web-tile:hover { border-color: var(--matcha); background: var(--matcha-soft); box-shadow: var(--shadow-sm); }
.web-tile .web-name { font-weight: 700; color: var(--ink); font-size: var(--f-md); }
.web-tile .web-url { font-size: var(--f-xs); color: var(--ink-faint); margin-top: 2px; word-break: break-all; }
.web-tile .web-type {
  margin-top: 8px; display: inline-block; background: var(--matcha-soft); color: var(--sage-deeper);
  padding: 2px 10px; border-radius: var(--r-pill); font-size: var(--f-xs); font-weight: 600; border: 1px solid var(--matcha);
}
.web-tile .web-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.web-tile.web-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border-style: dashed; color: var(--ink-faint); min-height: 96px;
}
.web-tile.web-add:hover { border-color: var(--sage); background: var(--matcha-soft); color: var(--sage-deep); }
.web-tile .web-add-ico { font-size: 40px; line-height: 1; }
.web-tile .web-add-txt { font-weight: 600; }

/* 时政卡片：教师备注（浅黄色） */
.li-teacher-note { background: var(--butter-soft); border-radius: var(--r-md); padding: 10px 12px; margin-top: 8px; }
.li-teacher-note-body { font-size: var(--f-sm); color: var(--ink-soft); white-space: pre-wrap; }

/* ============ 第7阶段补完：午休暖黄渐变（个人/班级课表一致） ============ */
.sched .lesson.rest { background: linear-gradient(135deg, #F6D98C, #E9B84A); color: #5a4410; }
.sched .lesson.rest .c, .sched .lesson.rest .cls { color: #5a4410; opacity: 1; }
/* 第8阶段B：午休方块在个人 / 班级课表中排版完全一致（不受 .personal / .classmode 字号差异影响），
   且高度与普通课程一致（继承 .sched .lesson 的 min-height） */
.sched .lesson.rest .c { font-size: 13px; font-weight: 800; line-height: 1.3; }
.sched .lesson.rest .cls { font-size: 12px; font-weight: 700; line-height: 1.3; }
.sched .lesson.rest .note { font-size: 11px; font-weight: 600; line-height: 1.3; }

/* 待办分层：已过期（红）/ 今日（强调）/ 未来（弱化），明显但克制 */
.todo-item.todo-overdue { background: var(--danger-soft); }
.todo-item.todo-today { border-left: 3px solid var(--sage); }
.todo-item.todo-future { opacity: .72; }

/* 题干预览：第8阶段改为真正完整显示（不设高度上限、不滚动、不截断） */
.q-stem-full { max-height: none; overflow: visible; }

/* ============ 第8阶段：课表文字层级 / 题库筛选 / 待办分段 / 自适应高度 ============ */

/* 课表色块文字层级：个人课表（班级名称最醒目）/ 班级课表（课程名称最醒目） */
.sched .lesson.personal .cls { font-size: 15px; font-weight: 800; line-height: 1.25; }
.sched .lesson.personal .c { font-size: 12px; font-weight: 600; opacity: .95; }
.sched .lesson.classmode .c { font-size: 15px; font-weight: 800; line-height: 1.25; }
.sched .lesson.classmode .cls { font-size: 11px; opacity: .9; }
.sched .lesson .chapter { font-size: 11px; opacity: .82; margin-top: 2px; }
.sched .lesson .note { font-size: 11px; opacity: .92; margin-top: 2px; }
.sched .lesson.rest .note { color: #5a4410; opacity: 1; }

/* 题库题型 / 类别筛选：选中显示真实白色方块，未选中保持原站点风格 */
.qtype-filter .chip-toggle.on { background: #ffffff; color: var(--ink); border-color: var(--sage-deep); box-shadow: 0 1px 3px rgba(62,74,60,.18); font-weight: 700; }
.seg.qtype-filter { flex-wrap: wrap; }
.seg.qtype-filter button.on { background: #ffffff; color: var(--ink); box-shadow: 0 1px 3px rgba(62,74,60,.18); font-weight: 700; }
/* 类别筛选独立成行并自动换行，不与题型筛选挤在一行 */
#subFilter { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
#subFilter .sub-filter-label { flex: 0 0 auto; }

/* 题库卡片：题干富文本 + 选择题选项完整内联显示（含图片/表格） */
.q-card-opts { margin: 6px 0 2px; }
.q-card-opts .q-opt { background: transparent; border: none; padding: 2px 0; margin: 0; align-items: flex-start; }
.q-card-opts .q-opt.ok { background: transparent; }
.q-card-opts .q-opt .opt-text { white-space: pre-wrap; }
.q-opt-img { max-width: 120px; max-height: 80px; border-radius: 6px; }
.list-item .q-rich img { max-width: 100%; max-height: 260px; }
.list-item .q-rich table { max-width: 100%; }

/* 待办事项分层段落标题（Req7）：今日事项 > 已过期 > 未来事项 > 已完成 */
.todo-sec-head { font-size: var(--f-sm); font-weight: 800; color: var(--sage-deeper); margin: 14px 0 8px; display: flex; align-items: center; gap: 8px; }
.todo-sec-head .cnt { font-size: var(--f-xs); font-weight: 600; color: var(--ink-faint); }
.todo-item.todo-done { opacity: .72; }

/* 富文本输入区自适应高度（Req20）：随内容增长/收缩，达到上限后允许内部滚动 */
.rt-area { resize: none; overflow-y: hidden; }

/* ============ 第8阶段B ============ */

/* 备课资源中心：「备课网站」独立置顶板块，与下方教材资源树在视觉上明确区分 */
.res-web-card {
  margin: 0 0 var(--s-5);
  background: linear-gradient(180deg, var(--butter-soft) 0%, var(--cream-2) 100%);
  border: 1px solid var(--butter);
  border-left: 4px solid var(--warn);
}
.res-web-card .card-head h3 { color: var(--ink); }
/* 教材资源树区段标题：与备课网站板块形成层级分隔 */
.res-section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: var(--s-6) 0 var(--s-3);
  padding-top: var(--s-4);
  border-top: 1px dashed var(--line);
}
.res-section-head h3 { font-size: var(--f-md); font-weight: 800; color: var(--sage-deeper); margin: 0; }
.res-section-head .sub { font-size: var(--f-xs); color: var(--ink-faint); }

/* 文件中心：① 选择文件类型 与 ② 点击或拖拽文件到此处上传 —— 字号/字重/行高/颜色完全一致 */
.file-step-label {
  font-size: var(--f-md);
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
  letter-spacing: 0;
  text-transform: none;
  padding: 0;
  margin: 0;
}
.file-step-hint { font-size: var(--f-sm); color: var(--ink-faint); line-height: 1.5; }

/* 文件卡片操作区：固定「下载 → 删除」顺序，间距适中且移动端友好 */
.file-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.file-actions .link-btn { padding: 4px 2px; }
.file-actions .fa-del { color: var(--danger); }
@media (max-width: 640px) {
  .file-actions { gap: 18px; }
  .file-actions .link-btn { padding: 6px 4px; }
}
