:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1e293b;
  --text-dim: #64748b;
  --border: #e5e7eb;
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.06);
  --rail-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ============ 布局 ============ */
#app { min-height: 100vh; }

.rail {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--rail-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  z-index: 20;
}

.main {
  margin-left: var(--rail-w);
  min-height: 100vh;
  padding: 0 28px 40px;
}

.topbar { display: none; }
.appbar { display: none; }

/* ============ 导航 rail ============ */
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 20px;
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  object-fit: cover;
  display: block;
}
.brand-name { font-weight: 700; font-size: 18px; }

.rail-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  color: var(--text-dim); font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 18px; width: 22px; text-align: center; }

.rail-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 10px; border-top: 1px solid var(--border);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
  flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-class { font-size: 12px; color: var(--text-dim); }

.icon-btn {
  border: none; background: transparent; color: var(--text-dim);
  font-size: 17px; border-radius: 8px; padding: 6px 8px;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* 退出登录：红色描边按钮，hover 红色填充 */
.logout-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 1.5px solid var(--danger); background: transparent;
  color: var(--danger); font-size: 13px; font-weight: 600;
  border-radius: 9px; padding: 7px 12px; cursor: pointer;
  transition: background .15s, color .15s; white-space: nowrap;
}
.logout-btn:hover { background: var(--danger); color: #fff; }
.logout-btn:active { transform: scale(.97); }
.rail-user + .logout-btn { width: 100%; margin-top: 12px; }

/* 积分徽章 */
.points-badge {
  display: inline-flex; align-items: center; gap: 2px;
  background: #fef9c3; color: #a16207; border: 1px solid #fde047;
  font-size: 12.5px; font-weight: 700; border-radius: 999px;
  padding: 2px 10px; white-space: nowrap; flex-shrink: 0;
}

/* ============ 顶部（移动端） ============ */
.topbar {
  position: sticky; top: 0; z-index: 15;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
}
.topbar-title { font-weight: 700; font-size: 17px; }
.topbar-user { font-size: 13px; color: var(--text-dim); }

/* ============ 通用卡片 / 标题 ============ */
.page { max-width: 1100px; margin: 0 auto; }
.page-head { margin: 28px 0 20px; }
.page-title { font-size: 24px; font-weight: 700; margin: 0; }
.page-sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px;
}

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* ============ 表单 ============ */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; background: var(--surface);
  color: var(--text); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field .hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.form-error {
  background: var(--danger-soft); color: var(--danger);
  padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px;
  display: none;
}
.form-error.show { display: block; }

/* ============ 登录页 ============ */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, #eef2ff 0%, #faf5ff 50%, #f0fdf4 100%);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-logo { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 12px; object-fit: cover; }
.auth-brand h1 { font-size: 22px; margin: 0 0 4px; }
.auth-brand p { color: var(--text-dim); font-size: 13px; margin: 0; }

.auth-tabs { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; border: none; background: transparent; padding: 9px; border-radius: 9px;
  font-size: 14px; font-weight: 500; color: var(--text-dim);
}
.auth-tab.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* QQ 授权：链接优先按钮 + 折叠二维码 */
.auth-link-btn {
  width: 100%; justify-content: center; padding: 14px 20px;
  font-size: 15px; font-weight: 700; border-radius: 14px;
  text-decoration: none;
}
.qrcode-details { width: 100%; margin-top: 4px; }
.qrcode-details summary {
  font-size: 13px; color: var(--text-dim); text-align: center; cursor: pointer;
  padding: 8px; border-radius: 8px; list-style: none; user-select: none;
}
.qrcode-details summary:hover { background: var(--bg); }
.qrcode-details summary::-webkit-details-marker { display: none; }

/* ============ 上传区 ============ */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 32px 20px; text-align: center; color: var(--text-dim);
  transition: border-color .15s, background .15s; cursor: pointer;
  margin-bottom: 18px;
}
.dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .dz-icon { font-size: 36px; }
.dropzone .dz-title { font-weight: 600; color: var(--text); margin: 8px 0 2px; }
.dropzone .dz-hint { font-size: 12px; }

.upload-queue { margin-bottom: 18px; display: none; }
.upload-queue.show { display: block; }
.progress { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 999px; width: 0; transition: width .2s; }
.upload-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; font-size: 13px;
}
.upload-item .fname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-item .fstatus { flex-shrink: 0; }

/* ============ 文件列表 ============ */
.file-list { display: flex; flex-direction: column; gap: 2px; }
.file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 10px;
}
.file-row:hover { background: var(--bg); }
.file-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 20px;
}
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 12px; color: var(--text-dim); }
.file-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* AI 轻应用列表 */
.app-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 10px;
}
.app-row:hover { background: var(--bg); }
.app-info { flex: 1; min-width: 0; }
.app-title { font-weight: 500; color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-title:hover { text-decoration: underline; }
.app-desc { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ============ 班级墙（全校作品展） ============ */
.search-box { position: relative; margin-bottom: 20px; }
.search-box input {
  width: 100%; padding: 12px 16px 12px 42px; border: 1px solid var(--border);
  border-radius: 12px; font-size: 14px; outline: none; background: var(--surface);
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-box .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-dim); }

.wall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

/* 项目卡片（按项目平铺） */
.project-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.proj-head { display: flex; align-items: center; gap: 10px; }
.proj-icon {
  width: 42px; height: 42px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.proj-main { flex: 1; min-width: 0; }
.proj-title { font-weight: 600; font-size: 15px; line-height: 1.35; word-break: break-all; }
.proj-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.proj-tag {
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); font-weight: 600;
  white-space: nowrap;
}
.proj-tag.tag-mine { background: var(--primary); color: #fff; }
.proj-author { font-size: 12px; color: var(--text-dim); }
.proj-desc { font-size: 13px; color: var(--text-dim); word-break: break-all; }
.proj-foot {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 10px; margin-top: auto; padding-top: 6px; border-top: 1px solid var(--border);
}
.proj-time { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.proj-lock { font-size: 15px; color: var(--text-dim); }

/* ============ 总览 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { text-align: left; }
.stat-card .stat-label { font-size: 13px; color: var(--text-dim); }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin-top: 2px; }

.class-card { margin-bottom: 14px; }
.class-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: none; text-align: left; padding: 0; cursor: pointer;
}
.class-head .class-title { font-weight: 600; font-size: 16px; flex: 1; }
.class-head .class-stats { font-size: 12px; color: var(--text-dim); }
.class-head .chevron { color: var(--text-dim); transition: transform .2s; }
.class-card.open .chevron { transform: rotate(180deg); }
.class-body { display: none; margin-top: 14px; }
.class-card.open .class-body { display: block; }

.student-row { border-top: 1px solid var(--border); }
.student-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; text-align: left; padding: 12px 4px; cursor: pointer;
}
.student-head .stu-name { font-weight: 500; flex: 1; }
.student-head .stu-stats { font-size: 12px; color: var(--text-dim); }
.student-files { display: none; padding: 0 4px 12px; }
.student-row.open .student-files { display: block; }
.student-files .file-row { padding: 8px; font-size: 14px; }

/* ============ 学AI 栏目 ============ */
.learn-chapter { margin-bottom: 16px; padding: 18px; }
.learn-chapter-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.learn-chapter-no { font-weight: 700; font-size: 16px; color: var(--primary); }
.learn-chapter-count { font-size: 12px; color: var(--text-dim); }
.learn-list { display: flex; flex-direction: column; }
.learn-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 8px; border-radius: 10px; text-decoration: none; color: var(--text);
  border-top: 1px solid var(--border);
}
.learn-item:first-child { border-top: none; }
.learn-item:hover { background: var(--primary-soft); }
.learn-item-no {
  font-size: 12px; color: var(--text-dim); font-weight: 700;
  margin-top: 3px; flex-shrink: 0; min-width: 34px;
}
.learn-item-main { flex: 1; min-width: 0; }
.learn-item-title { font-weight: 600; font-size: 15px; }
.learn-item-summary { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.learn-item-arrow { color: var(--text-dim); margin-top: 2px; flex-shrink: 0; }

.learn-back { margin-bottom: 14px; }
.learn-article { padding: 26px 28px; max-width: 760px; }
.learn-article-head { border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 18px; }
.learn-article-chapter { font-size: 13px; color: var(--primary); font-weight: 700; margin-bottom: 4px; }
.learn-article-title { font-size: 24px; margin: 0 0 8px; line-height: 1.4; }
.learn-article-summary { color: var(--text-dim); font-size: 14px; margin: 0; }
.learn-article-body { font-size: 15px; line-height: 1.85; }
.learn-article-body h1, .learn-article-body h2, .learn-article-body h3, .learn-article-body h4 {
  margin: 26px 0 10px; line-height: 1.4;
}
.learn-article-body h1 { font-size: 21px; }
.learn-article-body h2 { font-size: 19px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.learn-article-body h3 { font-size: 17px; }
.learn-article-body h4 { font-size: 15px; }
.learn-article-body p { margin: 10px 0; }
.learn-article-body ul, .learn-article-body ol { margin: 10px 0; padding-left: 24px; }
.learn-article-body li { margin: 5px 0; }
.learn-article-body blockquote {
  margin: 14px 0; padding: 10px 16px; border-left: 4px solid var(--primary);
  background: var(--primary-soft); border-radius: 0 10px 10px 0; color: var(--text);
}
.learn-article-body code {
  background: var(--bg); border-radius: 5px; padding: 1px 6px;
  font-size: 13px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.learn-article-body pre {
  background: #1e293b; color: #e2e8f0; border-radius: 10px;
  padding: 14px 16px; overflow-x: auto; margin: 14px 0;
}
.learn-article-body pre code { background: transparent; color: inherit; padding: 0; font-size: 13px; }
.learn-article-body a { color: var(--primary); }
.learn-article-body hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
.learn-article-body strong { font-weight: 700; }
.learn-article-body .md-table {
  width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px;
}
.learn-article-body .md-table th, .learn-article-body .md-table td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left; line-height: 1.6;
}
.learn-article-body .md-table th {
  background: var(--primary-soft); font-weight: 700; white-space: nowrap;
}
.learn-article-body .md-table tr:nth-child(even) td { background: var(--bg); }
.learn-article-body .md-table { display: block; overflow-x: auto; }

/* 章节任务区 */
.learn-tasks { margin-top: 30px; border-top: 2px solid var(--border); padding-top: 20px; }
.learn-tasks-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.learn-tasks-title { font-size: 19px; margin: 0; }
.learn-tasks-progress { font-size: 13px; font-weight: 700; color: var(--primary); }
.learn-tasks-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.learn-tasks-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #7c3aed); border-radius: 999px; transition: width .3s; }
.learn-tasks-hint { font-size: 12px; color: var(--text-dim); margin-bottom: 14px; }
.learn-task {
  display: flex; gap: 12px; padding: 16px 18px; margin-bottom: 12px;
  align-items: flex-start; border-left: 4px solid var(--border);
}
.learn-task-badge {
  flex-shrink: 0; font-size: 12px; font-weight: 700; padding: 3px 10px;
  border-radius: 999px; color: #fff; margin-top: 2px;
}
.badge-action { background: #16a34a; }
.badge-video { background: #ea580c; }
.badge-quiz { background: #4f46e5; }
.learn-task-body { flex: 1; min-width: 0; }
.learn-task-head { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.learn-task-desc { color: var(--text-dim); font-size: 13.5px; margin: 0 0 10px; line-height: 1.7; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.quiz-option {
  text-align: left; border: 1.5px solid var(--border); background: var(--surface);
  border-radius: 10px; padding: 10px 14px; font-size: 14px; cursor: pointer;
  color: var(--text); transition: border-color .15s, background .15s; line-height: 1.5;
}
.quiz-option:hover { border-color: var(--primary); }
.quiz-option.correct { border-color: var(--success); background: var(--success-soft); font-weight: 600; }
.quiz-option.wrong { border-color: var(--danger); background: var(--danger-soft); }
.quiz-opt-label { font-weight: 700; margin-right: 4px; }
.quiz-feedback { display: none; margin-top: 10px; font-size: 13.5px; }
.quiz-feedback.show { display: block; }
.quiz-fb-ok { color: var(--success); font-weight: 700; }
.quiz-fb-no { color: var(--danger); font-weight: 600; }
.quiz-explain { display: block; color: var(--text-dim); margin-top: 4px; }

/* 识别中加载动画（进度提示） */
.scan-loading { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 0; }
.scan-loading .spinner { margin: 0; width: 24px; height: 24px; border-width: 3px; }
.scan-loading p { font-size: 13px; color: var(--text-dim); margin: 0; animation: pulse-text 1.4s ease-in-out infinite; }
@keyframes pulse-text { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ============ 弹窗 ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: grid; place-items: center; z-index: 50; padding: 20px;
  animation: fade .15s;
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 22px; animation: pop .18s;
}
.modal-title { font-size: 17px; font-weight: 700; margin: 0 0 14px; }
.modal-body { font-size: 14px; color: var(--text); margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ============ Toast ============ */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1e293b; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: pop .2s;
}

/* ============ 积分榜 ============ */
.lb-list { display: flex; flex-direction: column; }
.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 6px; border-top: 1px solid var(--border); font-size: 14px;
}
.lb-row:first-child { border-top: none; }
.lb-row.lb-mine { background: var(--primary-soft); border-radius: 8px; margin: 2px -4px; padding: 9px 10px; }
.lb-rank { font-size: 16px; width: 34px; text-align: center; flex-shrink: 0; }
.lb-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-class { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.lb-points { font-weight: 700; color: #a16207; flex-shrink: 0; }
.lb-reason { flex: 1; min-width: 0; }
.lb-time { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }

/* ============ 空状态 / 加载 ============ */
.empty {
  text-align: center; color: var(--text-dim); padding: 48px 20px;
}
.empty .empty-icon { font-size: 44px; margin-bottom: 8px; }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 768px) {
  .rail { display: none; }
  .main { margin-left: 0; padding: 0 14px 88px; }
  .topbar { display: flex; }
  .appbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .appbar-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 0; font-size: 11px; color: var(--text-dim); border-radius: 10px;
  }
  .appbar-item.active { color: var(--primary); }
  .appbar-item .nav-icon { font-size: 20px; }
  .page-head { margin: 18px 0 14px; }
  .page-title { font-size: 20px; }
  .wall-grid { grid-template-columns: 1fr; }
  .file-meta { display: block; }
}
