/* ============================================================
   凯哥数学 · 作业系统
   ============================================================ */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --line: #e4e9f2;
  --line-strong: #d3dae8;
  --text: #182234;
  --text-2: #4d5975;
  --muted: #7c88a3;
  --primary: #3b5bdb;
  --primary-dark: #2f49b3;
  --primary-weak: #edf1ff;
  --accent: #f08c00;
  --accent-weak: #fff5e6;
  --green: #138a5a;
  --green-weak: #e7f7ef;
  --red: #d64545;
  --red-weak: #fdecec;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(24, 34, 52, 0.05);
  --shadow: 0 4px 18px rgba(24, 34, 52, 0.07);
  --shadow-lg: 0 14px 44px rgba(24, 34, 52, 0.16);
  --sidebar-w: 216px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
}

.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--muted);
}

/* ---------------- 登录页 ---------------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 480px at 12% -12%, #dfe7ff 0%, rgba(223, 231, 255, 0) 62%),
    radial-gradient(900px 420px at 100% 0%, #ffe9cf 0%, rgba(255, 233, 207, 0) 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: var(--surface);
  border-radius: 22px;
  padding: 34px 30px 28px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 8px;
}

.login-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, #6d5ce7 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.5px;
  box-shadow: 0 6px 16px rgba(59, 91, 219, 0.3);
}

.login-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.login-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 24px;
  padding-left: 53px;
}

.login-hint {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

/* ---------------- 通用表单 ---------------- */

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.12);
}

.textarea {
  resize: vertical;
  min-height: 76px;
  line-height: 1.65;
}

.textarea.code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 13.5px;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237c88a3' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.field-row {
  display: flex;
  gap: 10px;
}

.field-row > * {
  flex: 1;
  min-width: 0;
}

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 17px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 91, 219, 0.24);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--muted);
}

.btn-soft {
  background: var(--primary-weak);
  color: var(--primary);
}

.btn-soft:hover:not(:disabled) {
  background: #e0e7ff;
}

.btn-danger {
  background: var(--red-weak);
  color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: #fbd9d9;
}

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

.btn-lg {
  padding: 12px 22px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 7px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  border: none;
}

.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ---------------- 应用骨架 ---------------- */

.app-root {
  min-height: 100vh;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #6d5ce7 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  flex: none;
}

.brand-text {
  min-width: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.3;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background 0.13s, color 0.13s;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-weak);
  color: var(--primary);
  font-weight: 600;
}

.nav-item .ico {
  width: 18px;
  text-align: center;
  flex: none;
  opacity: 0.85;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-weak);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex: none;
}

.user-meta {
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11.5px;
  color: var(--muted);
}

.main {
  padding: 26px 30px 60px;
  max-width: 1180px;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin: 0;
  line-height: 1.3;
}

.page-desc {
  font-size: 13.5px;
  color: var(--muted);
  margin: 3px 0 0;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------------- 移动端顶栏 / 底栏 ---------------- */

.mobile-top {
  display: none;
}

.tabbar {
  display: none;
}

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-pad {
  padding: 18px 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.card-title {
  font-size: 15.5px;
  font-weight: 700;
  margin: 0;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.3;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.stat-value.accent {
  color: var(--accent);
}

/* ---------------- 列表 ---------------- */

.list {
  display: flex;
  flex-direction: column;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.12s;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background: var(--surface-2);
}

.list-item.static {
  cursor: default;
}

.list-item.static:hover {
  background: transparent;
}

.li-main {
  flex: 1;
  min-width: 0;
}

.li-title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.li-name {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.li-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  line-height: 1.7;
}

.li-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* ---------------- 标签 ---------------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.75;
  white-space: nowrap;
}

.tag-blue {
  background: var(--primary-weak);
  color: var(--primary);
}

.tag-green {
  background: var(--green-weak);
  color: var(--green);
}

.tag-orange {
  background: var(--accent-weak);
  color: #b26a00;
}

.tag-red {
  background: var(--red-weak);
  color: var(--red);
}

.tag-gray {
  background: #eef1f6;
  color: var(--muted);
}

/* ---------------- 空状态 ---------------- */

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted);
}

.empty-icon {
  font-size: 34px;
  opacity: 0.5;
  margin-bottom: 8px;
}

.empty-text {
  font-size: 14px;
}

/* ---------------- 弹窗 ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(18, 26, 40, 0.44);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 900;
  animation: fadeIn 0.14s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  /* 关键：内容超高时由 .modal-body 自己滚动，而不是把 footer 顶出视口 */
  overflow: hidden;
  animation: popIn 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes popIn {
  from {
    transform: translateY(10px) scale(0.98);
    opacity: 0;
  }
}

/* 尺寸档：sm 420 / 默认 560 / lg 760 / xl 980 */
.modal.sm {
  max-width: 420px;
}

.modal.lg,
.modal.wide {
  max-width: 760px;
}

.modal.xl {
  max-width: 980px;
}

.modal-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 22px 15px;
  border-bottom: 1px solid var(--line);
}

.modal-head-text {
  flex: 1;
  min-width: 0;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
  margin: 0;
}

.modal-sub {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 3px;
}

.modal-close {
  flex: none;
  width: 30px;
  height: 30px;
  margin: -3px -6px 0 0;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

.modal-close:hover {
  background: var(--surface-2);
  color: var(--text-2);
}

.modal-body {
  flex: 1 1 auto;
  /* 关键：没有 min-height:0，flex 子项不会收缩，内容会被裁掉且无法滚动 */
  min-height: 0;
  padding: 18px 22px;
  overflow: auto;
  overscroll-behavior: contain;
}

.modal-foot {
  flex: none;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* footer 左侧杂项（删除、提示等） */
.modal-foot-left {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------------- 表单栅格（弹窗内通用） ---------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}

.form-grid > .span-2 {
  grid-column: 1 / -1;
}

.form-section {
  margin: 0 0 18px;
}

.form-section:last-child {
  margin-bottom: 0;
}

.form-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 12px;
}

.form-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 5px;
}

.req {
  color: var(--red);
  margin-left: 2px;
}

.field-error .input,
.field-error .select,
.field-error .textarea {
  border-color: var(--red);
}

.field-error-text {
  font-size: 12px;
  color: var(--red);
  margin-top: 5px;
}

/* 图片/文件上传位 */
.upload-tile {
  width: 104px;
  height: 104px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  overflow: hidden;
  text-align: center;
  transition: border-color 0.14s, background 0.14s;
}

.upload-tile:hover {
  border-color: var(--primary);
  background: var(--primary-weak);
  color: var(--primary);
}

.upload-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 文件拖拽区 */
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 22px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.14s, background 0.14s;
}

.file-drop:hover,
.file-drop.drag {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.file-drop .fd-main {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  word-break: break-all;
}

.file-drop .fd-hint {
  font-size: 12px;
  color: var(--muted);
}

.file-drop.has-file {
  border-style: solid;
  border-color: var(--primary);
  background: var(--primary-weak);
}

.file-drop.has-file .fd-main {
  color: var(--primary);
}

.link-btn {
  border: none;
  background: none;
  padding: 0 2px;
  color: var(--primary);
  font-size: 12.5px;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.field-head > label {
  margin-bottom: 0;
}

/* 二选一卡片（作业形式等） */
.mode-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-pick > button {
  text-align: left;
  padding: 12px 13px;
  border: 1.5px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}

.mode-pick > button:hover {
  border-color: var(--primary);
}

.mode-pick > button.on {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.mode-pick .mp-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.mode-pick .mp-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 3px;
}

.mode-pick > button.on .mp-title {
  color: var(--primary);
}

@media (max-width: 640px) {
  .modal-mask {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }

  .modal-head {
    padding: 16px 16px 12px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-foot {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .mode-pick {
    grid-template-columns: 1fr;
  }
}

/* ---------------- Toast ---------------- */

.toast-host {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}

.toast {
  background: #232c3f;
  color: #fff;
  padding: 9px 17px;
  border-radius: 22px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease;
  max-width: 100%;
}

.toast.ok {
  background: #12734b;
}

.toast.err {
  background: #b93b3b;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ---------------- 数学内容 ---------------- */

.math-body {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.math-body .katex {
  font-size: 1.06em;
}

.math-body .katex-display {
  margin: 0.6em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}

.math-body p {
  margin: 0 0 0.5em;
}

.math-body p:last-child {
  margin-bottom: 0;
}

.mono {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

/* ---------------- 学生答题 ---------------- */

.student-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 110px;
}

.q-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.q-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.q-no {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--primary-weak);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12.5px;
  flex: none;
}

.q-score {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.q-stem {
  font-size: 15.5px;
  line-height: 1.75;
  margin-bottom: 12px;
}

.q-image {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin: 8px 0;
  display: block;
}

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

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 13px;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.13s;
  background: var(--surface);
}

.option:hover {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.option.selected {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.option.correct {
  border-color: var(--green);
  background: var(--green-weak);
}

.option.wrong {
  border-color: var(--red);
  background: var(--red-weak);
}

.option-key {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  flex: none;
  background: var(--surface);
}

.option.selected .option-key {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.option.correct .option-key {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.option.wrong .option-key {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.option-text {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}

.upload-row {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  flex: none;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(18, 26, 40, 0.68);
  color: #fff;
  border: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.upload-btn {
  width: 84px;
  height: 84px;
  border-radius: 10px;
  border: 1.5px dashed var(--line-strong);
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 12px;
  gap: 2px;
  flex: none;
  text-align: center;
  line-height: 1.3;
}

.upload-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-weak);
}

.upload-btn .plus {
  font-size: 20px;
  line-height: 1;
}

.sticky-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 120;
  align-items: center;
}

.sticky-bar .inner {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ---------------- 题目编辑 ---------------- */

.q-editor {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 14px;
  margin-bottom: 12px;
}

.q-editor-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.q-editor-body .field {
  margin-bottom: 10px;
}

.opt-edit {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-bottom: 6px;
}

.opt-edit .key {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  flex: none;
}

.preview-box {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  padding: 10px 12px;
  margin-top: 8px;
  min-height: 40px;
  font-size: 14.5px;
}

/* ---------------- 批改 ---------------- */

.grade-item {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.grade-item:last-child {
  border-bottom: none;
}

.grade-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ans-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14.5px;
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.ans-box.blank {
  color: var(--muted);
  font-style: italic;
}

.score-input {
  width: 74px;
  text-align: center;
  font-weight: 600;
}

/* ---------------- 作业照片墙 ---------------- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.photo-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  aspect-ratio: 3 / 4;
  cursor: zoom-in;
  transition: transform 0.15s, box-shadow 0.15s;
}

.photo-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 学生端大图上传区 */
.upload-hero {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.upload-hero:hover,
.upload-hero.dragover {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.upload-hero .big {
  font-size: 34px;
  margin-bottom: 6px;
}

.upload-hero .t1 {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.upload-hero .t2 {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}

.photo-grid.fill .photo-item {
  aspect-ratio: 3 / 4;
}

/* ---------------- 作业题目（图片 / PDF） ---------------- */

.paper-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.paper-thumb {
  position: relative;
  width: 118px;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  cursor: zoom-in;
  transition: transform 0.15s, box-shadow 0.15s;
}

.paper-thumb:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.paper-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  display: block;
}

.paper-order {
  position: absolute;
  left: 6px;
  top: 6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  background: rgba(18, 26, 40, 0.62);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.paper-file {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 260px;
  max-width: 100%;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.paper-file:hover {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.pf-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3px;
  display: grid;
  place-items: center;
}

.pf-main {
  min-width: 0;
  flex: 1;
}

.pf-name {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.upload-hero.upload-compact {
  padding: 16px;
  margin-top: 12px;
}

.upload-hero.upload-compact .big {
  font-size: 24px;
  margin-bottom: 2px;
}

.upload-hero.upload-compact .t1 {
  font-size: 14px;
}

.upload-hero.upload-compact .t2 {
  font-size: 12px;
}

/* ---------------- 积分商城 ---------------- */

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 620px) {
  .shop-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1000px) {
  .shop-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.shop-card .pic {
  aspect-ratio: 1;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}

.shop-card .pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.shop-card {
  display: flex;
  flex-direction: column;
}

.shop-card .body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.shop-card .tags {
  margin-top: auto;
  padding-top: 8px;
}

.shop-card .name {
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.35;
}

/* ---------------- 表格 ---------------- */

.table-wrap {
  overflow-x: auto;
}

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.tbl th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface-2);
}

table.tbl td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.tbl tr:last-child td {
  border-bottom: none;
}

table.tbl tbody tr:hover {
  background: var(--surface-2);
}

/* ---------------- 杂项 ---------------- */

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

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

.spacer {
  flex: 1;
}

.loading {
  display: grid;
  place-items: center;
  padding: 60px;
  color: var(--muted);
  font-size: 14px;
}

.spin {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.alert {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.alert-warn {
  background: var(--accent-weak);
  border-color: #ffdca8;
  color: #8a5200;
}

.alert-info {
  background: var(--primary-weak);
  border-color: #d3ddff;
  color: var(--primary-dark);
}

.alert-err {
  background: var(--red-weak);
  border-color: #f8cccc;
  color: #a52d2d;
}

.chip-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

/* 筛选条：状态 / 年级并排，右侧可放搜索或下拉 */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-sep {
  width: 1px;
  height: 22px;
  margin: 0 3px;
  background: #c8d1e2;
  align-self: center;
  flex: none;
}

.chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.13s;
}

.chip:hover {
  border-color: var(--primary);
}

.chip.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.progress {
  height: 5px;
  background: var(--line);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 8px;
}

.progress > div {
  height: 100%;
  background: var(--primary);
  transition: width 0.2s;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 980px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  .main {
    padding: 20px 18px 80px;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
    padding-top: 52px;
    padding-bottom: 62px;
  }
  .sidebar {
    display: none;
  }
  .mobile-top {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    z-index: 300;
  }
  .mobile-top .m-title {
    font-size: 15.5px;
    font-weight: 700;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 300;
  }
  .tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px 7px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
  }
  .tabbar-item .ico {
    font-size: 18px;
    line-height: 1;
  }
  .tabbar-item.active {
    color: var(--primary);
    font-weight: 700;
  }
  .main {
    padding: 16px 14px 30px;
  }
  .page-title {
    font-size: 20px;
  }
  .grid-4,
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  /* 带操作按钮的列表项在手机上换行，按钮独占一行更好点 */
  .list-item.static {
    flex-wrap: wrap;
  }
  .list-item.static .li-side {
    width: 100%;
    justify-content: flex-end;
    margin-top: 8px;
    gap: 6px;
  }
  .list-item.static .li-side .btn {
    padding: 4px 10px;
    font-size: 12.5px;
  }
  .card-pad {
    padding: 14px 15px;
  }
  .list-item {
    padding: 12px 14px;
  }
  .modal {
    max-height: 92vh;
  }
  .modal-head {
    padding: 16px 17px 10px;
  }
  .modal-body {
    padding: 2px 17px 6px;
  }
  .modal-foot {
    padding: 12px 17px 15px;
  }
  .student-shell {
    padding: 14px 12px 100px;
  }
  .q-card {
    padding: 15px;
  }
  .q-stem {
    font-size: 15px;
  }
}

@media (max-width: 420px) {
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .stat-value {
    font-size: 23px;
  }
}

@media print {
  .sidebar,
  .tabbar,
  .mobile-top,
  .sticky-bar,
  .no-print {
    display: none !important;
  }
  .shell {
    display: block;
    padding: 0;
  }
  .main {
    padding: 0;
  }
}

/* ---------------- 学生管理（名单 / 档案 / 考勤 / 账户） ---------------- */

.sm-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.sm-tab {
  position: relative;
  padding: 9px 16px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.sm-tab.on {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.sm-tab-num {
  font-size: 11.5px;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.6;
}

.sm-tab.on .sm-tab-num {
  background: var(--primary-weak);
  border-color: transparent;
  color: var(--primary);
}

.st-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.st-cell {
  flex: 1;
  min-width: 130px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.st-cell > span {
  font-size: 12px;
  color: var(--muted);
}

.st-cell > b {
  display: block;
  font-size: 20px;
  margin-top: 2px;
}

.st-cell > b em {
  font-size: 12px;
  font-style: normal;
  color: var(--muted);
  margin-left: 2px;
  font-weight: 500;
}

.st-cell.ok > b {
  color: var(--green);
}

.st-cell.late > b {
  color: #b26a00;
}

.st-cell.absent > b {
  color: var(--red);
}

.st-filters {
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.st-batch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: var(--primary-weak);
  border: 1px solid #dbe3ff;
}

.st-wrap {
  overflow-x: auto;
}

.st-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.st-table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.st-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.st-table tbody tr:hover td {
  background: var(--surface-2);
}

.st-table tr.st-inactive td {
  opacity: 0.62;
}

.st-check {
  width: 34px;
}

.st-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.st-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  flex: none;
}

.st-muted {
  color: var(--muted);
}

.st-login {
  font-size: 11.5px;
  margin-top: 1px;
}

.st-rate {
  display: flex;
  align-items: center;
  gap: 8px;
}

.st-bar {
  width: 56px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  flex: none;
}

.st-bar i {
  display: block;
  height: 100%;
}

.st-rate em {
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

.st-actions {
  display: flex;
  gap: 2px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.6;
}

.sm-seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}

.sm-seg button {
  border: none;
  background: var(--surface);
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  border-right: 1px solid var(--line);
}

.sm-seg button:last-child {
  border-right: none;
}

.sm-seg button.on {
  background: var(--green-weak);
  color: var(--green);
  font-weight: 700;
}

.sm-seg button.on.bad {
  background: var(--red-weak);
  color: var(--red);
}

.sm-perf {
  max-width: 110px;
}

.sm-note {
  min-width: 120px;
}

.sm-kv {
  font-size: 13px;
  line-height: 1.6;
}

.sm-kv > div {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
}

.sm-kv > div:last-child {
  border-bottom: none;
}

.sm-kv > div > span {
  width: 76px;
  flex: none;
  color: var(--muted);
  font-size: 12.5px;
}

.sm-pwbox {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  line-height: 1.9;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  white-space: pre-wrap;
  user-select: all;
}

.st-batch[hidden] {
  display: none;
}

/* ---------------- 教学反馈（iframe 面板） ---------------- */

.fb-frame-wrap {
  height: calc(100vh - 190px);
  min-height: 420px;
  display: flex;
}

.fb-frame {
  flex: 1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 900px) {
  .fb-frame-wrap {
    height: calc(100vh - 260px);
  }
}

/* ---------------- 积分商城卡片 ---------------- */

.reward-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.reward-thumb {
  position: relative;
  aspect-ratio: 1.55;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.reward-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reward-mask {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.74);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
}

.reward-name {
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.45;
}

.reward-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reward-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

/* 列表元信息分隔点：一串文字看起来更有层次（标签之间不加） */
.li-sub > span:not(.tag) + span:not(.tag)::before {
  content: '·';
  margin: 0 7px;
  color: var(--line-strong);
}

/* 数字输入去掉上下箭头，靠键盘或快捷按钮调整 */
input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
}
