/* ========== 班级错题本 — 仿 WineShop 淘宝风格 CSS（青蓝主题） ========== */

:root {
  --teal: #0F766E;
  --teal-dark: #0B5D57;
  --teal-light: #14B8A6;
  --price: #E53935;
  --answer-bg: #E8F5E9;
  --answer-border: #A5D6A7;
  --bg: #F7FAFA;
  --bg-gray: #f5f5f5;
  --surface: #FFF;
  --text: #1A1A1A;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #eee;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 8px;
  --tab-height: 56px;
  --top-height: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-gray);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  max-width: 750px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { border: none; background: none; font: inherit; cursor: pointer; color: inherit; }
input, textarea { font: inherit; }

/* ========== Top Bar ========== */
.top-bar {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 750px; height: var(--top-height);
  background: var(--teal); color: #fff;
  display: flex; align-items: center; padding: 0 12px;
  z-index: 100; box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.back-btn { font-size: 20px; padding: 4px 8px; margin-right: 4px; color: #fff; }
.top-title { flex: 1; font-size: 17px; font-weight: 600; text-align: center; margin-right: 40px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { width: 40px; display: flex; justify-content: flex-end; }
.top-action-btn { color: #fff; font-size: 14px; padding: 4px 6px; }

/* ========== Bottom Tab Bar ========== */
.tab-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 750px; height: calc(var(--tab-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; align-items: center; z-index: 100;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; color: var(--text-muted); font-size: 11px; padding: 4px 0;
}
.tab-item.active { color: var(--teal); }
.tab-icon { font-size: 22px; line-height: 1; }
.tab-label { margin-top: 2px; }

/* 中间创建大按钮 */
.tab-create {
  background: var(--teal); color: #fff !important; border-radius: 12px;
  padding: 6px 0 !important; margin-top: -18px; box-shadow: 0 -2px 8px rgba(15,118,110,0.35);
  min-height: 52px;
}
.tab-create:active { background: var(--teal-dark); }
.tab-icon-create { font-size: 28px; line-height: 1; }

/* ========== Main Content ========== */
main { padding-bottom: 16px; }
main.has-tabbar { padding-bottom: calc(var(--tab-height) + var(--safe-bottom) + 16px); }
main.has-topbar { padding-top: calc(var(--top-height) + 8px); }
main:not(.has-topbar) { padding-top: 8px; }

/* ========== 统计横幅 ========== */
.stats-banner {
  margin: 8px 12px 4px; padding: 14px 18px;
  background: linear-gradient(135deg, var(--teal), var(--teal-light));
  border-radius: 12px; color: #fff;
  display: flex; justify-content: space-around; align-items: center;
  box-shadow: 0 2px 8px rgba(15,118,110,0.25);
}
.stats-item { text-align: center; }
.stats-num { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stats-label { font-size: 12px; opacity: 0.9; }

/* ========== Search Bar ========== */
.search-bar {
  margin: 8px 12px; display: flex; align-items: center;
  background: var(--surface); border-radius: 20px; padding: 8px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.search-bar input {
  flex: 1; border: none; outline: none; background: transparent; font-size: 14px; color: var(--text);
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-icon { font-size: 16px; margin-right: 8px; }

/* ========== Section ========== */
.section { margin: 0 12px 16px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.section-title { font-size: 17px; font-weight: 700; color: var(--text); }
.section-more { font-size: 13px; color: var(--text-muted); }

/* ========== 错题本卡片网格 ========== */
.nb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nb-grid.cols-1 { grid-template-columns: 1fr; }

.nb-card {
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; display: block; box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: transform 0.15s; position: relative;
}
.nb-card:active { transform: scale(0.98); }
.card-link { display: block; color: inherit; }

.nb-card-head {
  position: relative; width: 100%; padding-top: 62%;
  background: linear-gradient(135deg, #E0F2F1, #B2DFDB);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.nb-card-head .nb-avatar {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 44px; text-align: center;
}
.subject-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(15,118,110,0.85); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
}
.nb-card-body { padding: 8px 10px 10px; }
.nb-name {
  font-size: 15px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nb-count-row {
  margin-top: 4px; display: flex; align-items: baseline; justify-content: space-between;
}
.nb-count {
  color: var(--price); font-size: 16px; font-weight: 700;
}
.nb-count small { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.nb-time { font-size: 11px; color: var(--text-muted); }

/* ========== 错题本头部卡（详情页） ========== */
.nb-hero {
  margin: 0 12px 12px; padding: 18px;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); text-align: center;
}
.nb-hero-avatar { font-size: 48px; line-height: 1.2; }
.nb-hero-name { font-size: 20px; font-weight: 700; margin-top: 4px; }
.nb-hero-subject {
  display: inline-block; margin-top: 6px; padding: 3px 12px;
  background: #E0F2F1; color: var(--teal); font-size: 13px; border-radius: 12px;
}
.nb-hero-stats { margin-top: 10px; font-size: 13px; color: var(--text-secondary); }

/* ========== 错题卡片 ========== */
.q-card {
  margin: 0 12px 12px; padding: 14px;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.q-card-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.q-index {
  background: var(--teal); color: #fff; font-size: 13px; font-weight: 700;
  min-width: 26px; height: 26px; border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 8px;
}
.q-tag {
  background: #FFF3E0; color: #E65100; font-size: 12px;
  padding: 2px 10px; border-radius: 10px;
}
.q-date { font-size: 11px; color: var(--text-muted); margin-left: auto; }

.q-question { font-size: 15px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.q-img { margin-top: 8px; border-radius: 6px; max-height: 320px; object-fit: contain; background: #fafafa; cursor: zoom-in; }

.q-answer {
  margin-top: 10px; padding: 10px 12px;
  background: var(--answer-bg); border: 1px solid var(--answer-border);
  border-radius: 6px;
}
.q-answer-label {
  font-size: 12px; font-weight: 700; color: #2E7D32; margin-bottom: 4px;
  display: flex; align-items: center; gap: 4px;
}
.q-answer-text { font-size: 14px; color: #1B5E20; white-space: pre-wrap; word-break: break-word; }
.q-answer .q-img { cursor: zoom-in; }

/* ========== 表单 ========== */
.form-card {
  margin: 0 12px 12px; padding: 16px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.form-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid #ddd; border-radius: 6px; outline: none;
  background: var(--surface); color: var(--text);
}
.form-input:focus, .form-textarea:focus { border-color: var(--teal); }
.form-textarea { min-height: 90px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.btn {
  display: block; width: 100%; padding: 12px; font-size: 15px; font-weight: 600;
  border-radius: 8px; text-align: center; cursor: pointer;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:active { background: var(--teal-dark); }
.btn-danger { background: #fff; color: var(--price); border: 1px solid var(--price); }
.btn-plain { background: #f5f5f5; color: var(--text-secondary); }
.btn-sm {
  display: inline-block; width: auto; padding: 6px 14px; font-size: 13px;
  border-radius: 6px; font-weight: 500;
}
.btn-sm-primary { background: var(--teal); color: #fff; }
.btn-sm-danger { background: #fff; color: var(--price); border: 1px solid var(--price); }
.btn-sm-plain { background: #f0f0f0; color: var(--text-secondary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== 图片上传 ========== */
.img-uploader { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.img-pick {
  width: 88px; height: 88px; border: 1.5px dashed #ccc; border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px; cursor: pointer; background: #fafafa;
  position: relative; overflow: hidden;
}
.img-pick:active { border-color: var(--teal); }
.img-pick .pick-icon { font-size: 24px; line-height: 1; }
.img-preview {
  width: 88px; height: 88px; border-radius: 6px; overflow: hidden; position: relative;
  border: 1px solid var(--border); background: #fafafa;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-remove {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 12px; line-height: 20px;
  text-align: center; cursor: pointer;
}
.img-uploading { position: absolute; inset: 0; background: rgba(255,255,255,0.8); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--teal); }

/* ========== 弹层 ========== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  padding: 0 24px;
}
.modal {
  width: 100%; max-width: 420px; max-height: 86vh; overflow-y: auto;
  background: var(--surface); border-radius: 12px; padding: 20px;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; text-align: center; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ========== 密码门 ========== */
.pw-gate { text-align: center; padding: 40px 24px; }
.pw-gate-icon { font-size: 52px; }
.pw-gate-text { margin: 12px 0 20px; color: var(--text-secondary); font-size: 14px; }

/* ========== 空状态 ========== */
.empty {
  padding: 60px 24px; text-align: center; color: var(--text-muted);
}
.empty-icon { font-size: 56px; }
.empty-text { margin-top: 10px; font-size: 14px; }

/* ========== 后台表格 ========== */
.admin-table { margin: 0 12px; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.admin-row {
  display: flex; align-items: center; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.admin-row:last-child { border-bottom: none; }
.admin-row-main { flex: 1; min-width: 0; }
.admin-row-name { font-size: 15px; font-weight: 600; }
.admin-row-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.admin-row-count { color: var(--price); font-weight: 700; font-size: 15px; white-space: nowrap; }
.admin-row-actions { display: flex; gap: 6px; margin-left: 10px; flex-shrink: 0; }

/* ========== Toast ========== */
.toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.9);
  background: rgba(0,0,0,0.75); color: #fff; font-size: 14px;
  padding: 10px 20px; border-radius: 8px; z-index: 300;
  opacity: 0; pointer-events: none; transition: all 0.25s;
  max-width: 80%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ========== 图片放大层 ========== */
.img-zoom-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 250;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
  padding: 20px;
}
.img-zoom-mask img { max-width: 100%; max-height: 100%; }

/* ========== 审批相关 ========== */
.pending-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 14px;
}
.pending-row:last-of-type { border-bottom: none; }
.pending-badge {
  background: #FFF3E0; color: #E65100; font-size: 12px;
  padding: 3px 10px; border-radius: 10px; white-space: nowrap;
}

/* ========== 错题测验 ========== */
.quiz-progress { margin: 0 12px 12px; }
.quiz-progress-text { font-size: 14px; font-weight: 600; color: var(--teal); margin-bottom: 6px; text-align: center; }
.quiz-progress-bar {
  height: 8px; background: #E0F2F1; border-radius: 4px; overflow: hidden;
}
.quiz-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--teal), var(--teal-light));
  border-radius: 4px; transition: width 0.4s ease;
}
.my-answer-box {
  margin-top: 10px; padding: 10px 12px;
  background: #FFF8E1; border: 1px solid #FFE082;
  border-radius: 6px;
}
.my-answer-label { font-size: 12px; font-weight: 700; color: #F57F17; margin-bottom: 4px; }
.my-answer-text { font-size: 14px; color: #795548; white-space: pre-wrap; word-break: break-word; }

/* ========== 在线教学 · 御姐老师 ========== */
.teach-stage {
  position: relative;
  margin: 12px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, #F5F3FF 0%, #FDF2F8 60%, #FFF1F2 100%);
  border: 1px solid #F3E8FF;
  text-align: center;
  min-height: 250px;
}
.teach-stage canvas { display: block; margin: 0 auto; max-width: 100%; height: auto; touch-action: manipulation; }
.teach-avatar-fallback {
  font-size: 90px; line-height: 250px;
  animation: teach-float 2.6s ease-in-out infinite;
}
@keyframes teach-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.teach-stage-name {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  font-size: 13px; font-weight: 700; color: #7C3AED;
  background: rgba(255,255,255,.85); border-radius: 12px; padding: 3px 12px;
  box-shadow: var(--shadow);
}
.teach-stage-status {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: #6B21A8;
  background: rgba(255,255,255,.9); border-radius: 12px; padding: 3px 12px;
  white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
.teach-status-talk { background: #FDF2F8; color: #DB2777; }
.teach-stage-hint { font-size: 11px; color: #999; padding: 0 10px 8px; }

.teach-cam { margin-bottom: 4px; }
.teach-cam-video {
  width: 100%; border-radius: 8px; background: #000;
  max-height: 320px; object-fit: cover; margin-bottom: 8px;
}
.teach-live-toggle {
  display: block; font-size: 13px; color: var(--text-secondary);
  margin-bottom: 8px; cursor: pointer;
}
.teach-live-toggle input { vertical-align: -2px; margin-right: 6px; }

.teach-chat {
  margin: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 42vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.teach-msg { display: flex; gap: 8px; margin-bottom: 12px; align-items: flex-start; }
.teach-msg.user { flex-direction: row-reverse; }
.teach-avatar-mini {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
  background: #F5F3FF; border: 1px solid #EDE9FE;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.teach-msg-bubble {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.teach-msg.ai .teach-msg-bubble { background: #F8FAFC; border: 1px solid #E5E7EB; border-top-left-radius: 4px; color: var(--text); }
.teach-msg.user .teach-msg-bubble { background: linear-gradient(135deg, #7C3AED, #A855F7); color: #fff; border-top-right-radius: 4px; }
.teach-msg-img {
  display: block; max-width: 180px; max-height: 180px;
  border-radius: 8px; margin-bottom: 6px;
}
.teach-think { color: #999; font-size: 13px; }
.teach-dots i { animation: teach-blink 1.2s infinite; font-style: normal; }
.teach-dots i:nth-child(2) { animation-delay: .2s; }
.teach-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes teach-blink { 0%,100% { opacity: .2; } 50% { opacity: 1; } }
.teach-cursor { display: inline-block; animation: teach-blink .9s infinite; color: #A855F7; }
.teach-empty { text-align: center; color: #aaa; font-size: 13px; padding: 20px 0; }

.teach-input-row {
  display: flex; gap: 8px; align-items: center;
  margin: 0 12px 8px;
  position: sticky; bottom: 8px;
}
.teach-input { flex: 1; margin: 0; }
.teach-send { flex-shrink: 0; width: auto; padding: 12px 18px; }
.teach-mic {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid #EDE9FE; background: #F5F3FF; font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.teach-mic-on {
  background: #FEE2E2; border-color: #FCA5A5;
  animation: teach-pulse 1s infinite;
}
@keyframes teach-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.35); } 50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); } }
.teach-tts-row {
  display: flex; justify-content: space-between; align-items: center;
  margin: 0 16px 20px;
}
