/* ============== 全局 ============== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --fr-blue: #002395;
  --bg: #faf6f0;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #002395;
  --accent-hover: #001a73;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 4px 20px rgba(0, 35, 149, 0.08);
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
h1, h2, h3, h4 { font-family: 'Playfair Display', serif; font-weight: 700; }
.hidden { display: none !important; }
.emoji { font-style: normal; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code { background: #f3f4f6; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.85em; }

/* ============== 登录 ============== */
.auth-container {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(237, 41, 57, 0.05), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(0, 35, 149, 0.08), transparent 40%),
    var(--bg);
}
.auth-card {
  background: var(--card);
  width: 100%; max-width: 420px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.flag-stripe { height: 6px; background: linear-gradient(to right, var(--fr-blue) 33.3%, #fff 33.3%, #fff 66.6%, #ED2939 66.6%); }
.brand { text-align: center; font-size: 2.4rem; color: var(--accent); padding: 1.5rem 1.5rem 0.25rem; }
.brand-sub { text-align: center; color: var(--muted); font-size: 0.9rem; padding: 0 1.5rem 1.25rem; }
.tabs { display: flex; border-bottom: 1px solid var(--border); margin: 0 1.5rem; }
.tab {
  flex: 1; background: none; border: none; padding: 0.85rem;
  font-size: 0.95rem; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; font-weight: 500; font-family: inherit;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.form { display: none; padding: 1.5rem; gap: 0.85rem; flex-direction: column; }
.form.active { display: flex; }
.form label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 0.35rem; }
.form input, .form select, .form textarea {
  font-family: inherit; font-size: 0.95rem; padding: 0.6rem 0.75rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 35, 149, 0.1);
}
.form textarea { resize: vertical; min-height: 60px; }
.checkbox { flex-direction: row !important; align-items: center; gap: 0.5rem !important; color: var(--text) !important; }

/* ============== 按钮 ============== */
.btn-primary {
  background: var(--accent); color: white; border: none;
  padding: 0.7rem 1.2rem; border-radius: 8px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background 0.15s, transform 0.05s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: var(--muted); cursor: not-allowed; }
.btn-primary.big { padding: 0.95rem 1.5rem; font-size: 1.05rem; width: 100%; }
.btn-primary.sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn-secondary {
  background: var(--card); color: var(--accent); border: 1px solid var(--accent);
  padding: 0.55rem 1rem; border-radius: 6px; font-size: 0.85rem;
  cursor: pointer; font-family: inherit; font-weight: 500;
}
.btn-secondary:hover { background: rgba(0, 35, 149, 0.05); }
.btn-secondary.sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-danger {
  background: white; color: var(--danger); border: 1px solid var(--danger);
  padding: 0.4rem 0.75rem; border-radius: 6px; font-size: 0.8rem;
  cursor: pointer; font-family: inherit;
}
.btn-danger:hover { background: var(--danger); color: white; }
.btn-ghost {
  background: none; border: 1px solid var(--border);
  padding: 0.45rem 0.85rem; border-radius: 6px;
  font-size: 0.85rem; color: var(--muted); cursor: pointer; font-family: inherit;
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }

.form-msg { font-size: 0.85rem; text-align: center; min-height: 1.2em; }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--success); }

.toast {
  position: fixed; top: 20px; right: 20px;
  background: var(--success); color: white;
  padding: 0.6rem 1.2rem; border-radius: 8px; z-index: 200; font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast.error { background: var(--danger); }

/* ============== 主应用 ============== */
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 2rem; background: white;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand.small { font-size: 1.4rem; padding: 0; text-align: left; }
.user-info { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; flex-wrap: wrap; }
#user-greeting { color: var(--text); font-weight: 500; }
.role-badge {
  background: #ED2939; color: white; font-size: 0.7rem;
  padding: 0.15rem 0.5rem; border-radius: 999px; font-weight: 600;
}
.role-badge:empty { display: none; }

.app-main { max-width: 1080px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.hero { margin-bottom: 1.5rem; }
.hero h2 { font-size: 1.8rem; color: var(--accent); }
.hero-sub { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

.card {
  background: var(--card); border-radius: 12px; padding: 1.5rem;
  box-shadow: var(--shadow); margin-bottom: 1.5rem;
}
.card h3 { font-size: 1.15rem; color: var(--accent); margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }

/* ============== 课程卡片网格 ============== */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.course-card {
  border-radius: 12px; padding: 1.5rem; color: white;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative; overflow: hidden;
  min-height: 160px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.course-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.course-card .ct-title { font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 700; line-height: 1.3; }
.course-card .ct-desc { font-size: 0.85rem; opacity: 0.9; margin-top: 0.5rem; }
.course-card .ct-progress { margin-top: 1rem; }
.course-card .ct-bar { background: rgba(255,255,255,0.3); border-radius: 4px; height: 6px; overflow: hidden; margin-top: 0.4rem; }
.course-card .ct-bar-fill { background: white; height: 100%; transition: width 0.3s; }
.course-card .ct-meta { display: flex; justify-content: space-between; font-size: 0.8rem; opacity: 0.9; }
.course-card .ct-type { font-size: 0.7rem; padding: 0.15rem 0.5rem; background: rgba(255,255,255,0.25); border-radius: 999px; display: inline-block; margin-bottom: 0.5rem; }

/* ============== 任务列表 ============== */
.task-list { display: flex; flex-direction: column; gap: 0.6rem; }
.task-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem; background: var(--card);
  border-radius: 10px; box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
  transition: transform 0.1s;
}
.task-item:hover { transform: translateX(2px); }
.task-item.unlocked { border-left-color: var(--accent); cursor: pointer; }
.task-item.done { border-left-color: var(--success); }
.task-item.graded { border-left-color: var(--warning); }
.task-item.locked { opacity: 0.6; cursor: not-allowed; background: #f9fafb; }
.task-item .ti-num {
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.9rem; flex-shrink: 0;
}
.task-item.locked .ti-num { background: var(--muted); }
.task-item.done .ti-num { background: var(--success); }
.task-item.graded .ti-num { background: var(--warning); }
.task-item .ti-main { flex: 1; min-width: 0; }
.task-item .ti-title { font-weight: 600; font-size: 1rem; }
.task-item .ti-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
.task-item .ti-status { font-size: 0.75rem; padding: 0.2rem 0.65rem; border-radius: 999px; font-weight: 600; flex-shrink: 0; }
.status-done { background: #dcfce7; color: #166534; }
.status-graded { background: #fef3c7; color: #92400e; }
.status-pending { background: #dbeafe; color: #1e40af; }
.status-locked { background: #f3f4f6; color: #6b7280; }

/* ============== 任务详情 ============== */
.task-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.task-detail-header h2 { font-size: 1.6rem; color: var(--accent); }
.task-detail-header .task-meta { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; }
.section-title { font-family: 'Playfair Display', serif; font-size: 1.05rem; color: var(--accent); margin: 1.5rem 0 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.section-title::before { content: ''; width: 4px; height: 18px; background: var(--accent); border-radius: 2px; }

/* 资料列表 */
.material-list { display: flex; flex-direction: column; gap: 0.6rem; }
.material-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; background: var(--bg); border-radius: 8px;
  font-size: 0.9rem;
}
.material-item .mi-icon { font-size: 1.3rem; }
.material-item .mi-name { flex: 1; word-break: break-all; }
.material-item .mi-size { color: var(--muted); font-size: 0.8rem; }
.material-item .mi-actions { display: flex; gap: 0.4rem; }

/* 文本材料(老师发的说明) */
.text-material {
  background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--accent);
  padding: 1.25rem 1.5rem; border-radius: 8px;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1.05rem; line-height: 2.0; letter-spacing: 0.01em; color: var(--text);
  box-shadow: var(--shadow); max-width: 760px; margin-bottom: 1rem;
}
.text-material + .text-material { margin-top: 0.25rem; }

/* 上传/文件预览 */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 1.5rem; text-align: center; cursor: pointer;
  background: var(--bg); transition: all 0.15s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent); background: rgba(0, 35, 149, 0.03);
}
.upload-zone p { color: var(--muted); font-size: 0.9rem; }
.upload-zone .icon { font-size: 2rem; }
.file-list { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.file-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem; background: var(--bg); border-radius: 6px;
  font-size: 0.85rem;
}
.file-row .fr-name { flex: 1; word-break: break-all; }
.file-row .fr-size { color: var(--muted); font-size: 0.75rem; }
.file-row audio, .file-row video { height: 32px; max-width: 280px; }
.file-row img { max-width: 200px; max-height: 120px; border-radius: 4px; }

/* 媒体(学生提交的文件预览) */
.media-block { margin-top: 0.75rem; }
.media-block audio, .media-block video { width: 100%; max-width: 480px; border-radius: 8px; }
.media-block img { max-width: 100%; max-height: 400px; border-radius: 8px; border: 1px solid var(--border); }

/* 提交状态条 */
.submission-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1rem; border-radius: 8px;
  background: linear-gradient(135deg, rgba(0, 35, 149, 0.05), rgba(0, 35, 149, 0.02));
  border: 1px solid rgba(0, 35, 149, 0.1);
  margin-bottom: 1rem;
}
.submission-bar.graded { background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.02)); border-color: rgba(245, 158, 11, 0.2); }
.submission-bar strong { color: var(--accent); }
.submission-bar.graded strong { color: #92400e; }

/* 老师批改面板 */
.grading-box {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.02));
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 10px; padding: 1.25rem; margin-top: 1rem;
}
.grading-box h4 { color: #92400e; margin-bottom: 0.75rem; font-size: 1rem; }
.grade-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.grade-chip {
  padding: 0.4rem 0.9rem; border: 1px solid var(--border);
  border-radius: 6px; background: white; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 0.9rem;
}
.grade-chip.active { background: var(--accent); color: white; border-color: var(--accent); }

/* 公开作品墙 */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.feed-card {
  background: var(--card); border-radius: 12px; padding: 1.25rem;
  box-shadow: var(--shadow);
}
.feed-card .fc-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.feed-card .fc-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: white; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.feed-card .fc-name { font-weight: 600; font-size: 0.9rem; }
.feed-card .fc-task { font-size: 0.75rem; color: var(--muted); }
.feed-card .fc-text { font-size: 0.9rem; line-height: 1.6; white-space: pre-wrap; margin: 0.75rem 0; }
.feed-card .fc-grade { font-size: 0.75rem; color: #92400e; background: rgba(245, 158, 11, 0.1); padding: 0.2rem 0.6rem; border-radius: 999px; display: inline-block; }

/* ============== 老师后台 ============== */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: white; padding: 1.25rem; border-radius: 12px;
  box-shadow: var(--shadow); text-align: center; border-top: 3px solid var(--accent);
}
.stat-num { font-family: 'Playfair Display', serif; font-size: 2.2rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.65rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg); font-weight: 600; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: rgba(0, 35, 149, 0.02); }

.badge-yes { background: #dcfce7; color: #166534; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; display: inline-block; }
.badge-no { background: #fee2e2; color: #991b1b; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; display: inline-block; }
.badge-disabled { background: #f3f4f6; color: #6b7280; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; display: inline-block; }

.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.filter-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.filter-row label { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 0.3rem; }
.filter-row input, .filter-row select { padding: 0.3rem 0.5rem; border: 1px solid var(--border); border-radius: 4px; font-family: inherit; font-size: 0.85rem; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
.modal {
  background: white; border-radius: 12px; width: 100%;
  max-width: 520px; padding: 1.5rem;
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { color: var(--accent); margin-bottom: 1rem; }
.modal .form { display: flex; padding: 0; gap: 0.85rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* 输入类型选择器(老师) */
.input-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.input-type-chip {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.9rem; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
  background: white; font-size: 0.9rem;
}
.input-type-chip input { display: none; }
.input-type-chip:has(input:checked) { background: rgba(0, 35, 149, 0.08); border-color: var(--accent); color: var(--accent); font-weight: 500; }

/* 进度条(学生) */
.progress-bar { background: var(--bg); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar-fill { background: var(--success); height: 100%; transition: width 0.3s; }
.progress-cell { display: flex; align-items: center; gap: 0.5rem; }
.progress-pct { font-size: 0.8rem; color: var(--muted); min-width: 35px; }

/* 响应式 */
@media (max-width: 640px) {
  .app-header { padding: 0.75rem 1rem; flex-wrap: wrap; gap: 0.5rem; }
  .app-main { padding: 1.25rem 1rem 3rem; }
  .hero h2 { font-size: 1.4rem; }
  .user-info { font-size: 0.8rem; }
  .stat-num { font-size: 1.8rem; }
  .brand { font-size: 2rem; }
  .input-type-grid { grid-template-columns: 1fr; }
}
