:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #f0f3ee;
  --border: #dfe5dc;
  --text: #1b2a24;
  --text-muted: #5a6d65;
  --primary: #1f6f54;
  --primary-hover: #175943;
  --primary-soft: #e6f4ee;
  --accent: #d97706;
  --accent-soft: #fef3c7;
  --lobe: #4338ca;
  --lobe-2: #2563eb;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 18px rgba(27, 42, 36, 0.06);
  --shadow-lg: 0 12px 32px rgba(27, 42, 36, 0.11);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* 顶部导航栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #1f6f54, #2f9e75);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(31, 111, 84, 0.28);
}

.brand-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  display: block;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 按钮体系 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 11px;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 10px rgba(31, 111, 84, 0.22);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-lobe {
  background: linear-gradient(135deg, var(--lobe), var(--lobe-2));
  color: #fff;
  padding: 10px 18px;
  font-size: 15px;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.32);
}
.btn-lobe:hover {
  filter: brightness(1.07);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.4);
}

.btn-soft {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-soft:hover { background: #e5ece3; }

.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-soft); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger:hover { background: #fecaca; }

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
  border-radius: 13px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* 容器与卡片 */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

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

.card-title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* 学生登录选择页 */
.welcome-hero {
  text-align: center;
  margin: 10px auto 26px;
  max-width: 680px;
}

.welcome-hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.welcome-hero p {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}

.class-pills {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.class-pill {
  padding: 9px 18px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.class-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(31, 111, 84, 0.24);
}

.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.student-card {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform 0.14s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.student-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
}

.student-card-name {
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  word-break: break-all;
}

/* 主导航三大入口栏 (学生端) */
.portal-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  margin-bottom: 22px;
}

.portal-tab {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  transition: all 0.15s ease;
}

.portal-tab:hover {
  border-color: #9ec5b6;
  transform: translateY(-1px);
}

.portal-tab.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 6px 18px rgba(31, 111, 84, 0.13);
}

.portal-tab-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--surface-soft);
  display: grid;
  place-items: center;
  font-size: 24px;
  flex-shrink: 0;
}

.portal-tab.active .portal-tab-icon {
  background: var(--primary);
  color: #fff;
}

.portal-tab-title {
  font-size: 18px;
  font-weight: 800;
  display: block;
}

.portal-tab-desc {
  font-size: 13px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.portal-lobe-card {
  background: linear-gradient(135deg, #4338ca, #2563eb);
  color: #fff;
  border-radius: 16px;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.28);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.portal-lobe-card:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.portal-lobe-card .portal-tab-desc {
  color: rgba(255, 255, 255, 0.85);
}

/* 课次侧栏 + 素材列表布局 */
.lesson-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
  align-items: start;
}

.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lesson-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff;
  border: 1.5px solid var(--border);
  transition: all 0.14s ease;
}

.lesson-item:hover {
  border-color: #9ec5b6;
}

.lesson-item.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.lesson-item-title {
  font-weight: 700;
  font-size: 15px;
  display: block;
}

.lesson-item-meta {
  font-size: 12px;
  opacity: 0.78;
  margin-top: 3px;
  display: block;
}

/* 素材卡片 */
.material-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.material-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 2px 10px rgba(27, 42, 36, 0.04);
}

.material-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  margin-bottom: 10px;
}

.material-head > .muted,
.material-head > .row {
  flex-shrink: 0;
}

.new-mat-banner {
  background: #ecfdf5;
  border: 1.5px solid #6ee7b7;
  color: #065f46;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.footer-teacher-link {
  text-align: center;
  margin-top: 34px;
  font-size: 12px;
  color: #94a39c;
}
.footer-teacher-link a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.material-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.material-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-prompt { background: #e0f2fe; color: #0369a1; }
.badge-image { background: #dcfce7; color: #15803d; }
.badge-html { background: #ede9fe; color: #6d28d9; }
.badge-video { background: #ffedd5; color: #c2410c; }
.badge-audio { background: #fce7f3; color: #be185d; }
.badge-link { background: #f1f5f9; color: #334155; }
.badge-file { background: #f1f5f9; color: #334155; }
.badge-private { background: var(--accent-soft); color: #92400e; }
.badge-class { background: var(--primary-soft); color: var(--primary); }

.prompt-box {
  background: #f8faf8;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 15px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.65;
  max-height: 300px;
  overflow-y: auto;
}

.media-preview-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
  cursor: zoom-in;
  background: #f3f4f6;
}

.media-preview-video {
  width: 100%;
  max-width: 560px;
  max-height: 360px;
  border-radius: 10px;
  background: #000;
  display: block;
}

.media-preview-audio {
  width: 100%;
  max-width: 460px;
  display: block;
}

.material-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* 表单与拖拽上传区 */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 6px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 84, 0.12);
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

.dropzone {
  border: 2px dashed #9cb8ac;
  background: #f8fbf9;
  border-radius: 14px;
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.dropzone-title {
  font-size: 15px;
  font-weight: 700;
}

.dropzone-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.file-chip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 13px;
}

.file-chip-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-bar {
  height: 8px;
  background: #e2e8e4;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1f6f54, #2fb380);
  width: 0%;
  transition: width 0.15s ease;
}

/* 老师端 Tabs 与看板 */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 11px 18px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -1.5px;
  transition: all 0.14s ease;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.name-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin: 3px 4px 3px 0;
}

.name-tag.done {
  background: #dcfce7;
  color: #166534;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.14s ease, transform 0.12s ease;
}

.name-tag.done:hover {
  border-color: #16a34a;
  transform: translateY(-1px);
}

.media-file-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.name-tag.todo {
  background: #f1f5f9;
  color: #64748b;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

.grid-2-wide {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 18px;
  align-items: start;
}

.grid-2 > *, .grid-2-wide > * {
  min-width: 0;
}

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: #f8faf8;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.check-pill input { margin: 0; accent-color: var(--primary); }

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 14px;
}

/* 弹窗大图预览与 Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 20, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal-img {
  max-width: 92vw;
  max-height: 86vh;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-close-float {
  position: fixed;
  top: 18px;
  right: 20px;
  background: rgba(255, 255, 255, 0.92);
  color: #1b2a24;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.modal-close-float:hover { background: #fff; }

.modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1b2a24;
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.space-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.muted { color: var(--text-muted); font-size: 13px; }

.hidden { display: none !important; }

@media (max-width: 820px) {
  .portal-switcher {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .portal-lobe-card {
    grid-column: 1 / -1;
    padding: 12px 16px;
    min-width: 0;
  }
  .portal-tab {
    padding: 12px 14px;
    gap: 10px;
  }
  .portal-tab-icon {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }
  .portal-tab-title { font-size: 16px; }
  .portal-tab-desc { font-size: 12px; }
  .lesson-layout { grid-template-columns: 1fr; }
  .grid-2, .grid-2-wide { grid-template-columns: 1fr; }
  .tab-btn { padding: 9px 11px; font-size: 14px; }
  .lesson-list { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .lesson-item { min-width: 170px; flex-shrink: 0; }
}

@media (max-width: 520px) {
  .portal-switcher { grid-template-columns: 1fr; }
}
