:root {
  --bg: #f6f3ec;
  --bg-strong: #efe9dd;
  --card: #fffdf9;
  --ink: #23262b;
  --muted: #6f6b63;
  --line: #e5ded1;
  --primary: #3f5d8c;
  --primary-ink: #2f476e;
  --primary-soft: #e7edf7;
  --green: #3f8a62;
  --green-soft: #e5f2ea;
  --amber: #a8802f;
  --amber-soft: #f7eed8;
  --red: #b0523c;
  --red-soft: #f8e6e0;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(48, 41, 28, 0.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom));
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0; }
small { font-size: 12px; }
ul { margin: 0; padding: 0; list-style: none; }

.muted { color: var(--muted); }
.tiny { font-size: 12px; color: var(--muted); }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.stack > * + * { margin-top: 12px; }

/* 顶部 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 10px;
  background: linear-gradient(var(--bg) 70%, rgba(246, 243, 236, 0.6));
  backdrop-filter: blur(8px);
}
.brand { font-weight: 800; color: var(--ink); letter-spacing: -0.02em; }
.who { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.who small { display: block; color: var(--muted); }
.who-name { max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-strong); font-size: 20px;
}

/* 主体 */
.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 18px calc(150px + var(--safe-bottom));
}
.app-main.narrow { max-width: 520px; }
.page-head { padding: 8px 0 14px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }

/* 卡片 */
.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card-soft { background: var(--primary-soft); border-color: #d7e0f0; box-shadow: none; }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }

/* 主任务卡 */
.task-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(150deg, #405e8e, #33486d);
  color: #fff;
  border-radius: 26px;
  padding: 22px;
  box-shadow: 0 18px 36px rgba(47, 71, 110, 0.22);
}
.task-card::after {
  content: "";
  position: absolute;
  right: -40px; top: -60px;
  width: 180px; height: 180px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}
.task-kicker { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.75; }
.task-card h2 { margin: 8px 0 6px; font-size: 26px; }
.task-card p { opacity: 0.85; }
.task-card .btn { margin-top: 18px; }

/* 按钮 */
.btn, .option, .chip-btn, .tabbar a, .input, .select, .textarea {
  touch-action: manipulation;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease;
  background: var(--bg-strong);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-ink); }
.btn-light { background: #fff; color: var(--primary-ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; white-space: nowrap; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* 统计 */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  text-align: left;
}
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat strong { font-size: 26px; letter-spacing: -0.02em; }
.stat.green strong { color: var(--green); }
.stat.amber strong { color: var(--amber); }

/* 列表 */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.list-row:first-child { border-top: 0; padding-top: 4px; }
.list-row .icon {
  flex: none; width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--bg-strong); font-size: 18px;
}
.list-row .title { display: block; font-weight: 600; }
.list-row .meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.list-row .right { margin-left: auto; flex: none; text-align: right; }

/* 标签 */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg-strong); color: var(--muted);
  font-size: 12px; white-space: nowrap;
}
.chip.primary { background: var(--primary-soft); color: var(--primary-ink); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red); }
/* 小测倒计时：最后一分钟转红提醒 */
#quiz-timer { font-variant-numeric: tabular-nums; font-weight: 700; }
#quiz-timer.urgent {
  background: var(--red-soft); color: var(--red);
  animation: quiz-pulse 1s ease-in-out infinite;
}
@keyframes quiz-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn {
  flex: none; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font-size: 14px; cursor: pointer;
}
.chip-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 表单 */
.form-field { margin-top: 14px; }
.form-field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-family: inherit;
  outline: none;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 进度条 */
.bar { display: block; height: 8px; border-radius: 999px; background: var(--bg-strong); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 92px; margin-top: 12px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart .col b { width: 100%; max-width: 26px; border-radius: 8px 8px 4px 4px; background: var(--primary-soft); }
.chart .col b.has { background: var(--primary); }
.chart .col span { font-size: 10px; color: var(--muted); }

/* 选项 */
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  position: relative;
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%; min-height: 56px; padding: 14px 16px;
  border-radius: 16px; border: 1.5px solid var(--line);
  background: #fff; color: var(--ink); font-size: 16px; text-align: left;
  cursor: pointer;
}
.option .letter {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--bg-strong);
  font-size: 13px; font-weight: 700;
}
.option input[type="radio"],
.option input[type="checkbox"] {
  position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none;
}
.option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.option:has(input:checked) .letter {
  background: var(--primary); color: #fff;
}
.option.correct { border-color: var(--green); background: var(--green-soft); }
.option.wrong { border-color: var(--red); background: var(--red-soft); }
.option.chosen { border-color: var(--primary); }

/* 反馈 */
.feedback { border-radius: 18px; padding: 16px; margin-top: 14px; }
.feedback.ok { background: var(--green-soft); color: #245f42; }
.feedback.warn { background: var(--amber-soft); color: #7a5a1c; }
.feedback.bad { background: var(--red-soft); color: #7f3424; }
.feedback h4 { margin-bottom: 6px; }

/* 空状态 */
.empty { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* 提示条 */
.flashes { max-width: 720px; margin: 0 auto; padding: 0 18px; }
.flash {
  border-radius: 14px; padding: 12px 14px; margin: 8px 0;
  background: var(--green-soft); color: #245f42; font-size: 14px;
}
.flash.warn { background: var(--amber-soft); color: #7a5a1c; }
.flash.error { background: var(--red-soft); color: #7f3424; }

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  max-width: 720px; margin: 0 auto;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: rgba(255, 253, 249, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; text-align: center; padding: 6px 4px;
  color: var(--muted); font-size: 11px; border-radius: 12px;
}
.tabbar a .ti { display: block; font-size: 20px; line-height: 1.4; }
.tabbar a.active { color: var(--primary-ink); background: var(--primary-soft); }

/* 登录 */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .logo { font-size: 34px; }
.auth-card h1 { margin: 6px 0 4px; }

/* 详情 */
.quote {
  border-left: 3px solid var(--primary-soft);
  padding: 2px 0 2px 14px; color: var(--muted);
}
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* 后台表格 */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }

/* 打印：重做卷 */
@media print {
  .topbar, .tabbar, .no-print, .flashes,
  .assistant-fab, .assistant-panel, .assistant-backdrop { display: none !important; }
  body { background: #fff; }
  .app-main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .print-page { page-break-after: always; }
}

@media (max-width: 420px) {
  h1 { font-size: 24px; }
  .task-card h2 { font-size: 22px; }
  .stats-row { gap: 8px; }
  .stat strong { font-size: 22px; }
}

.hidden { display: none !important; }

.photo {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  object-position: top center;
  border-radius: 14px;
  background: var(--bg-strong);
}

.source-link a { word-break: break-word; color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

/* 上传页：自定义选图 */
.file-input {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
.file-drop {
  display: block; padding: 22px 16px; text-align: center;
  border: 1.5px dashed var(--line); border-radius: 18px; background: #fff;
  cursor: pointer;
}
.file-drop:active { border-color: var(--primary); background: var(--primary-soft); }
.file-icon { display: block; font-size: 28px; }
.file-title { display: block; font-weight: 650; margin-top: 6px; }
.file-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.file-preview {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px;
}
.file-preview img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line);
}

/* 固定在底部操作条 */
.action-bar {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: 0;
  max-width: 720px; margin: 0 auto;
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(246, 243, 236, 0), var(--bg) 35%);
}
.action-bar.with-tabbar { bottom: calc(72px + var(--safe-bottom)); }
.app-main.with-action { padding-bottom: calc(132px + var(--safe-bottom)); }
.app-main.with-action.with-tabbar { padding-bottom: calc(204px + var(--safe-bottom)); }

/* 后台表格横向滚动 */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { min-width: 460px; }

:where(input, select, textarea, button) { font-family: inherit; }

@media (display-mode: standalone) {
  .tabbar { padding-bottom: calc(8px + var(--safe-bottom)); }
}

#next-btn { scroll-margin-bottom: calc(104px + env(safe-area-inset-bottom)); }

.card > .row-between > .row:last-child { margin-left: auto; }

@media (max-width: 380px) {
  .page-head h1 { font-size: 24px; }
  .page-head-actions > h1 { flex: 1 1 100%; }
  .page-head-actions > .row { margin-left: auto; }
}

@media (max-width: 560px) {
  .hide-sm { display: none; }
  .table { min-width: 0; }
}

.photo-wrap { position: relative; display: block; }
.photo-hint {
  position: absolute; right: 10px; bottom: 10px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(24, 24, 24, 0.58); color: #fff;
  font-size: 12px; letter-spacing: 0.02em;
}
.btn:focus-visible, .chip-btn:focus-visible, .option:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}


/* 学习助手 */
.assistant-fab {
  position: fixed; right: 16px; bottom: calc(86px + var(--safe-bottom));
  z-index: 40; display: inline-flex; align-items: center; gap: 9px;
  height: 54px; padding: 0 18px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 999px;
  background: linear-gradient(135deg, #4b6b9d 0%, #2f476e 58%, #243a5b 100%);
  color: #fff; box-shadow: 0 14px 30px rgba(35, 55, 86, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  font-size: 13px; font-weight: 700; letter-spacing: 0.02em; cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.assistant-fab:hover { transform: translateY(-2px); box-shadow: 0 18px 34px rgba(35, 55, 86, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.2); }
.assistant-fab:active { transform: scale(0.97); }
.assistant-fab:not(.with-tabbar) { bottom: calc(18px + var(--safe-bottom)); }
.assistant-fab-icon {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.14);
}
.assistant-fab-icon svg { width: 20px; height: 20px; }
.assistant-fab-label { line-height: 1; }

.assistant-backdrop {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(23, 28, 37, 0.42);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  animation: assistant-fade 0.18s ease-out;
}
.assistant-panel {
  position: fixed; left: 8px; right: 8px; bottom: calc(8px + var(--safe-bottom)); z-index: 50;
  height: min(86vh, 760px); height: min(86dvh, 760px); max-height: calc(100dvh - 16px);
  display: flex; flex-direction: column;
  background: var(--card); border-radius: 28px;
  box-shadow: 0 24px 70px rgba(22, 28, 36, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  overflow: hidden; animation: assistant-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.assistant-grab {
  width: 38px; height: 4px; flex: none; margin: 9px auto 0;
  border-radius: 999px; background: #ddd3c3;
}
.assistant-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 12px; flex: none;
  border-bottom: 1px solid rgba(229, 222, 209, 0.7);
  background: linear-gradient(180deg, #fffdf9, #fbf7ef);
}
.assistant-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.assistant-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #4b6b9d, #2f476e);
  color: #fff; font-size: 18px;
  box-shadow: 0 6px 14px rgba(47, 71, 110, 0.24);
}
.assistant-id b { display: block; font-size: 16px; letter-spacing: -0.01em; }
.assistant-id small {
  display: flex; align-items: center; gap: 5px;
  margin-top: 3px; color: var(--muted); font-size: 11px; white-space: nowrap;
}
.assistant-online {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: #54a978; box-shadow: 0 0 0 3px rgba(84, 169, 120, 0.12);
}
.assistant-head-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.assistant-back {
  display: none; width: 36px; height: 36px; flex: none; margin-left: -6px;
  border: 0; border-radius: 50%; cursor: pointer;
  background: var(--bg-strong); color: var(--muted);
  place-items: center;
}
.assistant-back svg { width: 18px; height: 18px; }
.assistant-new {
  display: inline-flex; align-items: center; gap: 5px;
  height: 36px; padding: 0 12px; border: 0; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-ink);
  font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s ease, transform 0.15s ease;
}
.assistant-new svg { width: 14px; height: 14px; }
.assistant-new:hover { background: #dfe8f5; }
.assistant-new:active { transform: scale(0.96); }
.assistant-history {
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.assistant-history svg { width: 18px; height: 18px; }
.assistant-history:hover { background: var(--bg-strong); color: var(--ink); }
.assistant-close {
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--bg-strong); color: var(--muted);
}
.assistant-close svg { width: 17px; height: 17px; }
.assistant-panel.list-view .assistant-messages,
.assistant-panel.list-view .assistant-suggestions,
.assistant-panel.list-view .assistant-form { display: none; }
.assistant-panel:not(.list-view) .assistant-threads { display: none; }
.assistant-panel:not(.list-view) .assistant-back { display: none; }
.assistant-panel.list-view .assistant-back { display: grid; }

.assistant-messages {
  flex: 1; overflow-y: auto; padding: 14px 14px 10px;
  display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(180deg, #fbf8f1 0%, #fffdf9 55%);
  -webkit-overflow-scrolling: touch;
}
.assistant-row { display: flex; align-items: flex-end; gap: 8px; }
.assistant-row.user { justify-content: flex-end; }
.assistant-mini-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none; margin-bottom: 2px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #4b6b9d, #2f476e);
  color: #fff; font-size: 12px;
  box-shadow: 0 4px 10px rgba(47, 71, 110, 0.18);
}
.assistant-bubble {
  max-width: calc(100% - 36px); padding: 11px 14px;
  border-radius: 18px 18px 18px 6px;
  font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
  background: #fff; border: 1px solid #eee5d7;
  box-shadow: 0 5px 14px rgba(48, 41, 28, 0.045);
}
.assistant-row.user .assistant-bubble {
  max-width: 82%; margin-left: auto; border: 0;
  border-radius: 18px 18px 6px 18px;
  background: linear-gradient(135deg, #4b6b9d, #2f476e);
  color: #fff; box-shadow: 0 8px 20px rgba(47, 71, 110, 0.2);
}
.assistant-bubble.error { background: var(--red-soft); border-color: #efc9bd; color: #7f3424; }
.assistant-sources { margin-top: 10px; padding-top: 8px; border-top: 1px dashed #e6dccb; }
.assistant-sources a {
  display: flex; align-items: flex-start; gap: 6px;
  margin-top: 4px; padding: 6px 8px; border-radius: 10px;
  background: #f7f2e8; color: var(--primary-ink);
  font-size: 11.5px; line-height: 1.45; text-decoration: none;
  word-break: break-word;
}
.assistant-sources a::before { content: "↗"; flex: none; color: var(--primary); font-weight: 700; }
.assistant-sources a:hover { background: var(--primary-soft); }
.assistant-meta {
  margin-top: 6px; font-size: 10px; color: #a89f92;
  opacity: 0.85; text-align: right;
}
.assistant-row.user .assistant-meta { color: rgba(255, 255, 255, 0.75); }

.assistant-typing { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.assistant-dots { display: inline-flex; gap: 3px; }
.assistant-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: #a9a49a;
  animation: assistant-blink 1.1s infinite ease-in-out;
}
.assistant-dots i:nth-child(2) { animation-delay: 0.15s; }
.assistant-dots i:nth-child(3) { animation-delay: 0.3s; }

.assistant-welcome { text-align: center; padding: 24px 10px 10px; }
.assistant-welcome-icon {
  width: 48px; height: 48px; margin: 0 auto 10px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 20px;
  background: linear-gradient(135deg, #4b6b9d, #2f476e);
  box-shadow: 0 10px 24px rgba(47, 71, 110, 0.24);
}
.assistant-welcome h4 { font-size: 18px; }
.assistant-welcome p {
  max-width: 280px; margin: 8px auto 0;
  color: var(--muted); font-size: 12.5px; line-height: 1.7;
}
.assistant-welcome-history {
  display: block; margin: 6px auto 0; padding: 8px 14px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--primary); font-size: 12.5px; font-weight: 600;
}
.assistant-welcome-history:hover { background: var(--primary-soft); }

.assistant-threads {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  background: linear-gradient(180deg, #fbf8f1 0%, #fffdf9 55%);
}
.assistant-threads-list {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.assistant-threads-empty {
  margin: 30px 20px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.7;
}
.assistant-thread {
  display: flex; align-items: stretch; gap: 6px;
  border: 1px solid #eee5d7; border-radius: 16px; background: #fff;
  box-shadow: 0 4px 12px rgba(48, 41, 28, 0.04);
}
.assistant-thread.current { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.assistant-thread-main {
  flex: 1; min-width: 0; padding: 11px 6px 11px 13px;
  border: 0; background: transparent; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 3px;
}
.assistant-thread-main b {
  font-size: 13.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.assistant-thread-main small {
  color: var(--muted); font-size: 11.5px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.assistant-thread-time { font-size: 10.5px; color: #b3aa9c; }
.assistant-thread-del {
  flex: none; width: 40px; margin: 8px 8px 8px 0; border: 0; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; color: #b3aa9c;
  transition: background 0.15s ease, color 0.15s ease;
}
.assistant-thread-del svg { width: 17px; height: 17px; }
.assistant-thread-del:hover { background: var(--red-soft); color: #a04b32; }
.assistant-clear-all {
  flex: none; margin: 10px 14px calc(12px + var(--safe-bottom));
  padding: 11px; border: 1px solid #efc9bd; border-radius: 14px;
  background: transparent; color: #a04b32; font-size: 13px; cursor: pointer;
}
.assistant-clear-all:hover { background: var(--red-soft); }

.assistant-suggestions {
  display: flex; gap: 8px; flex: none;
  padding: 0 14px 8px; overflow-x: auto;
  background: #fffdf9; scrollbar-width: none;
}
.assistant-suggestions::-webkit-scrollbar { display: none; }
.assistant-suggestions button {
  flex: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 12px; background: #fff; color: var(--primary-ink);
  font-size: 12px; white-space: nowrap; cursor: pointer;
}
.assistant-suggestions button:hover { background: var(--primary-soft); border-color: #cdd9ec; }

.assistant-form {
  flex: none; padding: 8px 12px calc(8px + var(--safe-bottom));
  border-top: 1px solid rgba(229, 222, 209, 0.8); background: var(--card);
}
.assistant-composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 5px 5px 5px 14px;
  border: 1px solid var(--line); border-radius: 22px; background: #fff;
  box-shadow: 0 6px 18px rgba(48, 41, 28, 0.05);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.assistant-composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.assistant-input {
  flex: 1; min-width: 0; min-height: 40px; max-height: 120px;
  padding: 9px 0; border: 0; outline: none; resize: none;
  background: transparent; color: var(--ink);
  font-size: 16px; line-height: 1.45;
}
.assistant-input::placeholder { color: #a29b90; }
.assistant-send {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: linear-gradient(135deg, #4b6b9d, #2f476e); color: #fff;
  box-shadow: 0 6px 14px rgba(47, 71, 110, 0.25);
}
.assistant-send:disabled { opacity: 0.55; cursor: default; }
.assistant-send svg { width: 19px; height: 19px; }
.assistant-footnote { margin: 6px 2px 0; text-align: center; color: var(--muted); font-size: 10.5px; }

body.assistant-open { overflow: hidden; }
@keyframes assistant-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes assistant-up {
  from { transform: translateY(24px) scale(0.98); opacity: 0.6; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes assistant-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* 图片灯箱 */
.back-link {
  display: inline-block; margin-bottom: 6px;
  color: var(--muted); font-size: 13px; font-weight: 600;
  text-decoration: none; padding: 4px 10px 4px 0;
}
.back-link:hover { color: var(--ink); }
.lightbox {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 18, 24, 0.88);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  padding: 14px; animation: assistant-fade 0.15s ease-out;
}
.lightbox img {
  max-width: 100%; max-height: calc(100dvh - 56px);
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lightbox-close {
  position: absolute; top: calc(10px + var(--safe-top, 0px)); right: 14px;
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16); color: #fff; font-size: 16px; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }
body.lightbox-open { overflow: hidden; }

/* 批改等待的不确定进度条 */
.bar-indeterminate { position: relative; overflow: hidden; background: #eee7da; }
.bar-indeterminate i {
  display: block; width: 34%; height: 100%;
  background: linear-gradient(90deg, #4b6b9d, #2f476e);
  animation: bar-slide 1.4s ease-in-out infinite;
}
@keyframes bar-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(340%); }
}

@media (min-width: 720px) {
  .assistant-panel {
    left: auto; right: 22px; bottom: 22px;
    width: 430px; height: min(74vh, 640px); max-height: none;
    border-radius: 26px;
  }
  .assistant-grab { display: none; }
  .assistant-head { padding-top: 14px; }
}

.current-role { color: var(--primary); font-weight: 700; }

@media (max-width: 420px) {
  .perm-table thead { display: none; }
  .perm-table, .perm-table tbody, .perm-table tr, .perm-table td { display: block; width: 100%; }
  .perm-table tr { padding: 9px 0; border-bottom: 1px solid var(--line); }
  .perm-table tr:last-child { border-bottom: 0; }
  .perm-table td { border: 0; padding: 1px 0; }
  .perm-table td:first-child { font-weight: 600; font-size: 14px; }
  .perm-table td:nth-child(2), .perm-table td:nth-child(3) {
    display: inline-flex; gap: 4px; margin-right: 12px;
    font-size: 12px; color: var(--muted); width: auto;
  }
  .perm-table td:nth-child(2)::before { content: "孩子 "; }
  .perm-table td:nth-child(3)::before { content: "家长 "; }
  .perm-table td.current-role { color: var(--primary); font-weight: 700; }
}

/* 错题多选 */
.mistake-item { position: relative; }
.mistake-item + .mistake-item { margin-top: 14px; }
.mistake-card { display: block; position: relative; }
.mistake-item .pick {
  display: none; position: absolute; z-index: 3; top: 16px; left: 16px;
}
.mistake-item .pick input { width: 22px; height: 22px; accent-color: var(--primary); }
body.select-mode .mistake-item .pick { display: block; }
body.select-mode .mistake-item .mistake-card { padding-left: 48px; }
.select-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 14px; margin-bottom: 12px;
  border-radius: 16px; background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.select-bar.hidden { display: none; }
.select-info { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; width: 100%; }
.select-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; justify-content: flex-end; }
body.select-mode .assistant-fab { display: none; }
@media (max-width: 380px) {
  .page-head-actions > .row { flex-wrap: wrap; justify-content: flex-end; }
}

/* 批改结果：卷面缩略图与逐题人工改判 */
.paper-thumb {
  display: block; margin-top: 10px; border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; background: #fff;
}
.paper-thumb img {
  display: block; width: 100%; height: 120px; object-fit: cover; object-position: center;
}
.verdict-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.verdict-row form { margin: 0; }
.verdict-row .chip-btn { min-height: 36px; }
.verdict-row .chip-btn.ok.active {
  background: var(--green-soft); color: var(--green); border-color: var(--green);
}
.verdict-row .chip-btn.bad.active {
  background: var(--red-soft); color: var(--red); border-color: var(--red);
}
