/* 教师题库平台 基础样式 */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: "Microsoft YaHei", "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif; background: #f1f5f9; color: #2d3436; }
body { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.12);
}
.brand-logo { font-size: 22px; font-weight: bold; letter-spacing: 1px; }
.brand-sub  { font-size: 13px; opacity: .8; margin-left: 12px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: rgba(255,255,255,.18); border-radius: 999px; font-size: 14px; }
.user-chip .avatar { width: 28px; height: 28px; border-radius: 50%; background: #fbbf24; color: #4f46e5; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; }
.btn-logout { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-logout:hover { background: rgba(255,255,255,.18); }

/* ---------- 标签页 ---------- */
.tabs { display: flex; background: #fff; border-bottom: 2px solid #e2e8f0; padding: 0 24px; }
.tab-btn { background: transparent; border: 0; padding: 14px 22px; font-size: 15px; cursor: pointer; color: #64748b; font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: color .15s, border-color .15s; }
.tab-btn:hover { color: #4f46e5; }
.tab-btn.active { color: #4f46e5; border-bottom-color: #4f46e5; font-weight: 600; }
.tab-panel { display: none; padding: 22px 24px; flex: 1; }
.tab-panel.active { display: block; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; padding: 14px 18px; background: #fff; border-radius: 12px; box-shadow: 0 2px 6px rgba(15,23,42,.06); }
.toolbar label { font-size: 13px; color: #475569; }
.toolbar select, .toolbar input[type=text] { padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; outline: none; }
.toolbar select:focus, .toolbar input:focus { border-color: #4f46e5; }
.toolbar .spacer { flex: 1; }
.btn { padding: 8px 18px; border: 0; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; transition: transform .08s, box-shadow .15s, background .15s; }
.btn-primary  { background: #4f46e5; color: #fff; box-shadow: 0 2px 0 #3730a3; }
.btn-primary:hover  { background: #4338ca; }
.btn-primary:active { transform: translateY(1px); box-shadow: 0 1px 0 #3730a3; }
.btn-secondary { background: #fff; color: #4f46e5; border: 1.5px solid #4f46e5; }
.btn-secondary:hover { background: #eef2ff; }
.btn-danger  { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- 表格 ---------- */
.qtable-wrap { background: #fff; border-radius: 12px; box-shadow: 0 2px 6px rgba(15,23,42,.06); overflow: hidden; }
.qtable { width: 100%; border-collapse: collapse; }
.qtable th { background: #f8fafc; color: #475569; text-align: left; padding: 12px 14px; font-size: 13px; font-weight: 600; border-bottom:2px solid #e2e8f0; }
.qtable td { padding: 14px; border-bottom: 1px solid #f1f5f9; vertical-align: top; font-size: 14px; }
.qtable tr:hover td { background: #f8fafc; }
.qtable tr.selected td { background: #eef2ff; }
.qtable .latex-cell { background: #fffbeb; padding: 8px 10px; border-radius: 6px; min-width: 200px; }
.qtable .latex-answer { color: #047857; font-size: 13px; margin-top: 4px; }
.qtable .latex-empty { color: #94a3b8; font-size: 13px; font-style: italic; }
.qtable .col-checkbox { width: 36px; }
.qtable .col-grade   { width: 80px; }
.qtable .col-author  { width: 90px; }
.qtable .col-actions { width: 180px; white-space: nowrap; }
.qtable .grade-pill { display: inline-block; padding: 3px 10px; background: #ddd6fe; color: #5b21b6; border-radius: 999px; font-size: 12px; font-weight: 600; }
.empty-row { text-align: center; color: #94a3b8; padding: 60px 20px; font-size: 14px; }

/* ---------- 模态框 ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal.show { display: flex; }
.modal-card { background: #fff; border-radius: 14px; max-width: 880px; width: 100%; max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-card.narrow { max-width: 460px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid #e2e8f0; }
.modal-title { font-size: 18px; font-weight: 600; color: #1e293b; margin: 0; }
.modal-close { background: transparent; border: 0; font-size: 22px; cursor: pointer; color: #64748b; padding: 0 6px; }
.modal-body { padding: 22px 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 10px; }
.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 6px; }
.field > input, .field > textarea, .field > select { width: 100%; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; font-family: inherit; outline: none; }
.field > input:focus, .field > textarea:focus, .field > select:focus { border-color: #4f46e5; }
.field > textarea { min-height: 70px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox-line { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #475569; }

/* ---------- 用户搜索 ---------- */
.search-users { display: flex; gap: 8px; margin-bottom: 12px; }
.search-users input { flex: 1; }
.user-results { max-height: 260px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 6px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: background .1s; }
.user-row:hover { background: #f8fafc; }
.user-row.selected { background: #eef2ff; }
.user-row .avatar { width: 32px; height: 32px; border-radius: 50%; background: #ddd6fe; color: #5b21b6; display: flex; align-items: center; justify-content: center; font-weight: bold; }
.user-row .uname { flex: 1; font-weight: 500; }
.user-row .uphone { color: #64748b; font-size: 13px; }
.selected-users { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0; min-height: 32px; border: 1px dashed #cbd5e1; border-radius: 6px; padding: 6px 10px; margin-bottom: 12px; }
.selected-users .chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; background: #ddd6fe; color: #5b21b6; border-radius: 999px; font-size: 12px; }
.selected-users .chip .x { cursor: pointer; opacity: .7; }
.selected-users .chip .x:hover { opacity: 1; }

/* ---------- 教研组 ---------- */
.group-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.group-card { background: #fff; border-radius: 12px; padding: 18px; box-shadow: 0 2px 6px rgba(15,23,42,.06); transition: transform .12s, box-shadow .12s; cursor: pointer; }
.group-card:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(15,23,42,.1); }
.group-card h3 { margin: 0 0 6px; font-size: 16px; color: #1e293b; }
.group-card .owner { color: #64748b; font-size: 13px; }
.group-card .stats { display: flex; gap: 14px; margin-top: 10px; color: #475569; font-size: 13px; }
.group-card .stats b { color: #4f46e5; }

.group-detail-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; padding: 16px 20px; background: #fff; border-radius: 12px; box-shadow: 0 2px 6px rgba(15,23,42,.06); }
.group-detail-header h2 { margin: 0; font-size: 18px; color: #1e293b; }
.group-detail-header .pill { background: #fef3c7; color: #92400e; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.members-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; background: #fff; border-radius: 12px; box-shadow: 0 2px 6px rgba(15,23,42,.06); margin-bottom: 16px; }
.member-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; background: #dbeafe; color: #1e40af; border-radius: 999px; font-size: 13px; }
.member-chip.owner { background: #fef3c7; color: #92400e; }
.member-chip .x { cursor: pointer; opacity: .6; margin-left: 2px; }
.member-chip .x:hover { opacity: 1; color: #dc2626; }

/* ---------- 登录 / 注册 ---------- */
.auth-card { max-width: 420px; padding: 30px; }
.auth-title { font-size: 22px; font-weight: 600; color: #1e293b; text-align: center; margin: 0 0 6px; }
.auth-sub { text-align: center; color: #64748b; font-size: 13px; margin-bottom: 22px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; background: #f1f5f9; border-radius: 8px; padding: 4px; }
.auth-tabs button { flex: 1; padding: 8px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; font-size: 14px; color: #64748b; }
.auth-tabs button.active { background: #fff; color: #4f46e5; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.auth-error { background: #fee2e2; color: #b91c1c; padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-top: 12px; min-height: 22px; }

/* ---------- 通知 toast ---------- */
.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); background: #1e293b; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px; box-shadow: 0 8px 20px rgba(0,0,0,.2); z-index: 200; display: none; }
.toast.show { display: block; animation: toastIn .25s ease; }
.toast.error { background: #dc2626; }
.toast.success { background: #059669; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ---------- 编辑器：MathLive 字段 ---------- */
math-field { display: inline-block; width: 100%; min-height: 56px; padding: 10px 14px; border: 1.5px solid #cbd5e1; border-radius: 6px; background: #fff; font-size: 18px; }
math-field:focus-within { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
math-field.large { min-height: 84px; font-size: 22px; }
.latex-display { font-size: 18px; padding: 8px 12px; background: #fffbeb; border-radius: 6px; display: inline-block; }
.latex-display.answer { background: #ecfdf5; }
.latex-display.large { font-size: 22px; padding: 12px 16px; }

/* 滚动条美化 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* 移动端适配 */
@media screen and (max-width: 760px) {
  .topbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .brand-logo { font-size: 18px; }
  .brand-sub { display: none; }
  .tabs { padding: 0 10px; overflow-x: auto; }
  .tab-btn { padding: 12px 14px; font-size: 14px; }
  .tab-panel { padding: 14px; }
  .toolbar { padding: 12px; gap: 8px; }
  .qtable th, .qtable td { padding: 8px; font-size: 13px; }
  .qtable .col-author, .qtable .col-actions { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .modal-card { max-width: 96vw; }
}