/* 全局样式:手机优先,桌面自适应。类名与旧版兼容。 */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f7fa; --card: #fff; --line: #e5eaf1;
  --text: #1b2838; --muted: #64748b;
  --primary: #2563eb; --primary-dk: #1d4ed8; --primary-soft: #eff4ff;
  --ok: #16803c; --ok-soft: #e7f7ee;
  --warn: #b45309; --warn-soft: #fdf3d7;
  --bad: #b91c1c; --bad-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 12px;
  --content-max: 1200px;   /* 分级版心:屏幕越宽给越宽,见文件底部媒体查询 */
}
html { min-width: 320px; background: var(--bg); }
body { min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
a { color: var(--primary); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible { outline: 3px solid rgba(37, 99, 235, .3); outline-offset: 2px; }

/* ---------- 顶栏与导航 ---------- */
.topbar { position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .88); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
.topbar-inner { width: 96%; min-height: 56px; margin: 0 auto;
  padding: 8px 0; display: flex; align-items: center; gap: 18px; }
.brand-link { display: inline-flex; align-items: center; gap: 10px; min-width: 0;
  color: var(--text); text-decoration: none; font-weight: 700; }
.brand-link:hover { opacity: .85; }
.brand-logo { display: block; width: 42px; height: 42px; padding: 1px; flex: 0 0 auto;
  object-fit: contain; filter: drop-shadow(0 2px 3px rgba(91, 21, 81, .2)); }
.brand-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.user-nav { min-width: 0; flex: 1; display: flex; align-items: center; gap: 12px; }
.nav-links { min-width: 0; flex: 1; display: flex; align-items: center; gap: 4px; }
.nav-links a { display: inline-flex; align-items: center; min-height: 34px; padding: 4px 13px;
  border-radius: 999px; color: var(--muted); text-decoration: none; white-space: nowrap;
  font-size: 14px; font-weight: 500; transition: background .12s ease, color .12s ease; }
.nav-links a:hover { color: var(--text); background: #eef2f7; }
.nav-links a.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.nav-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  margin-left: 5px; padding: 0 5px; border-radius: 999px; background: var(--bad);
  color: #fff; font-size: 11px; font-weight: 700; line-height: 1; }
.nav-links a.nav-quiet { margin-left: auto; }          /* 改密从这开始靠右弱化 */
.nav-links a.nav-quiet ~ a.nav-quiet { margin-left: 0; }
.nav-links a.nav-quiet { font-size: 13px; color: #94a3b8; }
.nav-links a.nav-quiet:hover { color: var(--text); }
.user-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 10px 3px 4px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font-size: 13px; color: var(--text); }
.user-chip .avatar { display: grid; place-items: center; width: 24px; height: 24px;
  border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 700; }
.user-chip .role { color: var(--muted); font-size: 12px; }

/* ---------- 版心与卡片 ---------- */
.wrap { width: 96%; margin: 0 auto; padding: 16px 0 64px; }
.page-lead { border-top: 3px solid var(--primary); }
.card { min-width: 0; margin-top: 14px; padding: 16px 18px; overflow-x: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow-wrap: anywhere; }
.card h3 { margin-bottom: 8px; font-size: 16px; line-height: 1.4; }
.card p { max-width: 90ch; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 14px; margin-top: 14px; }
.card-grid > .card { margin-top: 0; height: 100%; }
.wide-grid { display: grid; gap: 14px; margin-top: 14px; }
.wide-grid > .card { margin-top: 0; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.grow { min-width: 0; flex: 1 1 220px; }

/* ---------- 标签 / 按钮 ---------- */
.tag { display: inline-block; max-width: 100%; margin: 2px 6px 2px 0; padding: 2px 9px;
  overflow: hidden; border-radius: 999px; background: #e8edf5; color: #44546a;
  text-overflow: ellipsis; vertical-align: middle; white-space: nowrap; font-size: 12px; font-weight: 500; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
/* 测评类型配色:课前=诊断(蓝)/课后=验收(绿)/延迟=保留(橙)/补救=紫 */
.tag.k-pre { background: #e0edff; color: #1d4ed8; }
.tag.k-post { background: var(--ok-soft); color: var(--ok); }
.tag.k-delayed { background: var(--warn-soft); color: var(--warn); }
.tag.k-remedial { background: #f3e8ff; color: #7c3aed; }
.tag.q-single { background:#e0edff; color:#1d4ed8; }
.tag.q-multi { background:#e8f7ee; color:#16794b; }
.tag.q-judge { background:#fff2d8; color:#a55b00; }
.tag.q-fill { background:#f3e8ff; color:#7c3aed; }
.tag.q-qa { background:#e7f0ff; color:#234ea1; }
.tag.q-code { background:#1f2733; color:#e5edff; }
.locked-box { margin:12px 0; padding:12px 14px; border:1px solid #f1c56c;
  border-radius:9px; background:#fff8e8; color:#7a4b00; }
.check-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:7px 14px; margin:7px 0 14px; }
.check-grid label { display:flex; align-items:flex-start; gap:7px; color:var(--text); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
  padding: 8px 16px; border: 1px solid transparent; border-radius: 9px;
  background: var(--primary); color: #fff; cursor: pointer; text-align: center;
  text-decoration: none; font: inherit; font-size: 14px; font-weight: 500; line-height: 1.2;
  transition: background .13s ease, border-color .13s ease, box-shadow .13s ease; }
.btn:hover { background: var(--primary-dk); box-shadow: 0 2px 8px rgba(37, 99, 235, .3); }
.btn:active { transform: translateY(1px); }
.btn.ghost { border-color: #c4d4f0; background: #fff; color: var(--primary); box-shadow: none; }
.btn.ghost:hover { border-color: var(--primary); background: var(--primary-soft); box-shadow: none; }
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn.full { display: flex; width: 100%; margin-top: 14px; }

/* ---------- 表单 ---------- */
input[type=text], input[type=password], input[type=number], input[type=datetime-local],
input[type=url], input:not([type]), input[type=file], select, textarea { max-width: 100%; width: 100%; min-height: 40px;
  margin: 4px 0 12px; padding: 8px 11px; border: 1px solid #cfd9e7; border-radius: 8px;
  background: #fff; color: var(--text); font: inherit; font-size: 15px; }
/* 单行控件显式同高:裸 <input>(无 type,模板里 25 处)渲染为 text 但匹配不到
   input[type=text] 属性选择器,一直吃浏览器 UA 样式(高 19px);且 number(42.75)
   与 select(40)因 line-height 差异本就不齐。显式 height 让三者完全一致。 */
input[type=text], input[type=password], input[type=number], input[type=datetime-local],
input[type=url], input:not([type]), select { height: 42px; }
input[type=file] { height: auto; padding: 7px; }
/* 上面把 background 写死成 #fff,会盖掉浏览器对 disabled 的默认灰显,
   只读字段会看起来跟可编辑的一样。这条把只读态显式做出来。 */
input:disabled, select:disabled, textarea:disabled {
  background: #f2f5f9; color: var(--muted); cursor: not-allowed; }
/* 链接型资料的内嵌播放器。preload=none 由模板给,别改成 auto——
   一页十条录像会在打开页面时全部开始下载。 */
.media-embed { display: block; width: 100%; max-width: 560px; margin: 8px 0 2px;
  border-radius: 8px; background: #000; }
audio.media-embed { background: transparent; }
textarea { min-height: 86px; resize: vertical; }
label { color: var(--muted); font-size: 14px; }
.auth-card { width: min(100%, 420px); margin: 9vh auto 0; overflow: visible; }

/* ---------- 题目卡 ---------- */
.qcard { max-width: 860px; margin: 14px auto 0; padding: 16px 18px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); }
.qcard .stem { margin-bottom: 10px; font-weight: 600; }
.opt { display: flex; align-items: flex-start; gap: 10px; margin-top: 8px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
  transition: border-color .12s ease, background .12s ease; }
.opt:hover { border-color: #b9cdf2; }
.opt input { flex: 0 0 auto; margin-top: 5px; }
.opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- 表格(自适应关键) ----------
   表格保持 display:table 才会撑满卡片宽度;
   窄屏溢出由 .card / .table-scroll 的横向滚动兜底。 */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap;
  text-transform: none; letter-spacing: .02em; background: #fafbfd; }
tbody tr:hover, table tr:hover td { background: #fafcff; }
td form { max-width: 100%; }

/* ---------- 进度条 / 大分数 ---------- */
.bar { min-width: 60px; height: 8px; overflow: hidden; border-radius: 999px; background: #e6ebf2; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.bar.good > i { background: var(--ok); }
.bar.mid > i { background: #d97706; }
.bar.low > i { background: var(--bad); }
.score-big { color: var(--primary); font-size: 40px; font-weight: 750; }

/* ---------- 站内通知 ---------- */
.notice-list { padding: 4px 16px; }
.notice-item { display: flex; align-items: center; gap: 12px; padding: 13px 2px;
  border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.notice-item:last-child { border-bottom: 0; }
.notice-item:hover { background: #fafcff; }
.notice-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #cbd5e1; }
.notice-dot.unread { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.notice-body, .notice-item .muted { display: block; margin-top: 2px; }
.notice-body { color: var(--muted); font-size: 13px; font-weight: 400; }
.notice-arrow { flex: 0 0 auto; color: var(--primary); font-size: 13px; }

/* ---------- 响应式:版心恒为 96%(左右各留 2%),宽屏靠多列铺满 ---------- */
@media (min-width: 1500px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr)); }
  .card { padding: 18px 20px; }
}
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; min-height: auto; padding: 8px 0 6px; gap: 4px 10px; }
  .brand-logo { width: 38px; height: 38px; }
  .user-chip { margin-left: auto; }
  .user-chip .role { display: none; }
  .user-nav { width: 100%; }
  .nav-links { width: 100%; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { min-height: 32px; padding: 4px 11px; font-size: 13px; }
  .wrap { padding: 10px 0 48px; }
  .card { margin-top: 10px; padding: 13px 14px; border-radius: 10px; }
  .card-grid, .wide-grid { display: block; margin-top: 10px; }
  .card-grid > .card, .wide-grid > .card { margin-top: 10px; }
  .row { align-items: flex-start; gap: 8px; }
  .grow { flex-basis: 100%; }
  .action-item { align-items: flex-start; flex-wrap: wrap; }
  .btn { min-height: 42px; }
  .btn.sm { min-height: 36px; }
  table { font-size: 13px; }
  th, td { padding: 8px 7px; }
  .qcard { padding: 13px 14px; border-radius: 10px; }
  .auth-card { margin-top: 4vh; }
  .score-big { font-size: 34px; }
}

/* 登录锁定 banner(醒目) */
.lock-banner { display: flex; gap: 12px; align-items: flex-start;
  background: var(--bad-soft); border: 1.5px solid var(--bad);
  border-radius: 12px; padding: 13px 14px; margin: 10px 0 14px; }
.lock-banner .lock-icon { font-size: 24px; line-height: 1; flex: none; }
.lock-banner .lock-title { color: var(--bad); font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.lock-banner .lock-text { color: var(--bad); font-size: 13px; line-height: 1.5; }
.lock-banner .lock-text strong { font-size: 15px; }

/* ---------- 改错题：多样材料、统一文字作答 ---------- */
.tag.q-correction { background:#e7f0ff; color:#234ea1; }
.correction-material { margin:12px 0; border:1px solid var(--line); border-radius:10px; background:#fafcff; }
.material-block { padding:13px 14px; overflow-x:auto; }
.material-block + .material-block { border-top:1px solid var(--line); }
.material-block h5 { margin-bottom:8px; color:var(--muted); }
.material-text { white-space:pre-wrap; overflow-wrap:anywhere; }
.code-view, .student-code { overflow:auto; border-radius:8px; background:#172033; color:#edf2ff;
  font:13px/1.6 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; }
.code-view { padding:10px 0; }
.code-line { display:flex; min-width:max-content; padding:0 12px 0 0; }
.line-no { width:42px; flex:0 0 42px; padding-right:10px; color:#8290aa; text-align:right;
  user-select:none; border-right:1px solid #344057; margin-right:12px; }
.code-line code { white-space:pre; }
.student-code { padding:11px 13px; white-space:pre-wrap; }
.code-input { min-height:130px; font-family:ui-monospace, SFMono-Regular, Consolas, monospace; tab-size:4; }
.material-table { min-width:520px; background:#fff; }
.material-image-link { display:block; text-align:center; }
.material-image { display:block; max-width:min(100%,900px); max-height:65vh; margin:auto;
  object-fit:contain; border-radius:8px; border:1px solid var(--line); }
.correction-answer { margin-top:14px; }
.correction-answer textarea { min-height:105px; }
.hint-box, .answer-evidence, .grade-panel, .reference-answer { margin-top:12px; padding:12px 14px;
  border:1px solid var(--line); border-radius:9px; background:#fff; }
.hint-content { margin-top:8px; padding:9px 11px; border-left:3px solid var(--warn); background:var(--warn-soft); }
.rubric-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.grading-layout { display:grid; grid-template-columns:minmax(0,1.15fr) minmax(0,.85fr); gap:14px; }
.grading-layout > .card { min-width:0; }
.ai-suggestion { border-left:4px solid var(--warn); }
.answer-evidence p, .reference-answer p { margin-top:7px; white-space:pre-wrap; }
details > summary { cursor:pointer; color:var(--primary); font-weight:600; margin:8px 0; }

@media (max-width:760px) {
  .rubric-grid, .grading-layout { display:block; }
  .rubric-grid > label { display:block; }
  .material-image { max-height:50vh; }
}

/* ---------- 内容管理六页改版(2026-08-15) ---------- */
/* 行操作列:统一右对齐,按钮统一 .btn.sm.ghost;窄屏允许换行不挤压 */
td.ops, th.ops { text-align: right; white-space: nowrap; }
/* 识别信息(题干/标题/编码)加粗左对齐,次要信息灰色小字 */
.cell-title { font-weight: 600; }
.cell-sub { display: block; margin-top: 2px; color: var(--muted);
  font-size: 12.5px; font-weight: 400; }
/* 单行截断,全文放 title 属性(纯视觉截断,不改 HTML 文本) */
.truncate { max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub.truncate { max-width: 40ch; }
/* 新增/导入类表单收进可折叠区块(默认收起),列表成为页面主体 */
details.add-block { border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); }
details.add-block > summary { padding: 11px 14px; margin: 0; font-weight: 600;
  color: var(--primary); cursor: pointer; list-style: none; user-select: none; }
details.add-block > summary::-webkit-details-marker { display: none; }
details.add-block > summary::before { content: "＋ "; font-weight: 700; }
details.add-block[open] > summary::before { content: "－ "; }
details.add-block > summary:hover { background: var(--primary-soft); border-radius: 10px; }
details.add-block > form, details.add-block > .add-body { padding: 2px 14px 14px; }
/* 空状态:一句可操作的话 + 按钮 */
.empty-state { padding: 30px 16px; text-align: center; color: var(--muted); }
.empty-state .empty-actions { margin-top: 12px; display: flex; gap: 8px;
  justify-content: center; flex-wrap: wrap; }
@media (max-width: 768px) {
  td.ops, th.ops { white-space: normal; }
  .truncate { max-width: 30ch; }
}

/* 题库列表:题干下方的选项/答案预览(教师端专用,见 _macros.question_preview) */
/* 全文显示,不截断 —— 这些预览存在的意义就是"不用点进去看",
   截成省略号就等于没做(2026-09-02 报障)。改为在固定宽度内换行:
   限宽而不限行数,表格列宽仍然可控,内容一个字不少。 */
.opt-list { display: block; margin-top: 4px; max-width: 72ch;
            font-size: 12px; line-height: 1.8; color: var(--muted); }
.opt-list .opt { display: inline-block; margin-right: 12px; max-width: 100%;
                 white-space: normal; vertical-align: top; }
.opt-list .opt.correct { color: var(--ok); font-weight: 600; }
.opt-list .opt.wide { display: block; max-width: 100%; }
.opt-list .opt-bad { color: var(--bad); font-weight: 600; }
@media (max-width: 720px) { .opt-list { max-width: 100%; } }

/* 批改队列:题干下方的学生作答预览(见 _macros.correction_answer_preview) */
.corr-fix { display: block; margin-top: 4px; max-width: 72ch;
            white-space: normal;
            font-size: 12px; line-height: 1.7; color: var(--ok); font-weight: 600; }
.corr-fix.corr-empty { color: var(--muted); font-weight: 400; }
.corr-detail { margin-top: 2px; }
.corr-detail > summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.corr-detail .corr-body { max-width: 60ch; margin-top: 4px; padding: 6px 8px;
                          background: var(--bg); border-radius: var(--radius);
                          font-size: 12px; line-height: 1.7; }
.corr-detail .corr-body p { margin: 2px 0; white-space: normal; }
.corr-code { max-width: 100%; overflow-x: auto; white-space: pre;
             font-size: 12px; margin: 4px 0 0; }

/* 教师课程页的入口分层(见 templates/teacher_course.html) */
.dim-line { margin-top: 6px; font-size: 13px; color: var(--muted); }
.dim-line .tag { margin-left: 4px; text-decoration: none; }
.dim-line a.tag:hover { background: var(--primary-soft); color: var(--primary); }

/* 一层:日常上课要用的,常驻且醒目 */
.course-primary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.course-primary .btn { font-size: 14px; padding: 8px 16px; }

/* 二层:按用途分组,默认收起 */
.course-more { margin-top: 10px; }
.course-more > summary { display: inline-block; cursor: pointer; font-size: 13px;
                         color: var(--muted); padding: 4px 0; user-select: none; }
.course-more > summary:hover { color: var(--primary); }
.course-groups { display: grid; gap: 14px; margin-top: 10px;
                 grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.course-groups .cg { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
.course-groups .cg h4 { width: 100%; margin: 0 0 2px; font-size: 12px;
                        color: var(--muted); font-weight: 600; letter-spacing: .5px; }
.course-groups .roster-form { width: 100%; display: flex; flex-wrap: wrap;
                              gap: 6px; align-items: center; margin-top: 4px; }
.course-groups .roster-form input[type=file],
.course-groups .roster-form select { width: auto; margin: 0; font-size: 12px; }
.course-groups .roster-form .muted { width: 100%; font-size: 11px; line-height: 1.6; }
