/* aikc-homework-v2.css —— 作业区改造样式（r29）
 * 与 aikc-homework-v2.js 配套。配色沿用站点既有「墨绿 / 琥珀」体系。
 * 教师端：.aikc-hwd-*（作业评分台折叠详情）
 * 学生端：.aikc-hw-lang-*（提交语言 Python / C++ 切换）
 */

/* ============================================================
   ① 教师端 · 作业评分台：轮播模式（一次看一个学生，左右手动切换）
   ============================================================ */

/* 原生 <pre>{JSON.stringify(answers)}</pre> 太吵且不完整 → 隐藏，改由详情台展示 */
.submission-review-row.aikc-hwd-row > pre {
  display: none !important;
}

/* 导航条 */
.aikc-hwd-carousel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin: 6px 0 12px;
  padding: 12px 16px;
  border: 2px solid #26332e;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff9e8 0%, #fdf3d6 100%);
  box-shadow: 3px 4px 0 #26332e;
}

.aikc-hwd-nav {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #26332e;
  cursor: pointer;
  padding: 8px 18px;
  min-height: 38px;
  border: 2px solid #26332e;
  border-radius: 999px;
  background: #fff;
  transition: background .12s ease, transform .12s ease;
}

.aikc-hwd-nav:hover:not(:disabled) {
  background: #f6ad2f;
  transform: translateY(-1px);
}

.aikc-hwd-nav:disabled {
  opacity: .45;
  cursor: default;
}

.aikc-hwd-counter {
  font-size: 13px;
  font-weight: 800;
  color: #26332e;
  white-space: nowrap;
}

.aikc-hwd-carousel-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.aikc-hwd-who {
  font-size: 13px;
  color: #4a5b53;
  flex: 1 1 auto;
  min-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 详情台：当前学生的完整代码 / 文字 / 附件 */
.aikc-hwd-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 4px 0 20px;
  padding: 16px 18px;
  border: 2px dashed #d9cfae;
  border-radius: 14px;
  background: #fffdf6;
}

.aikc-hwd-stage:empty {
  display: none;
}

.aikc-hwd-badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .3px;
  border: 1.5px solid transparent;
}

.aikc-hwd-badge-py {
  background: #e6f4ff;
  color: #1b5f8f;
  border-color: #8ec8ee;
}

.aikc-hwd-badge-cpp {
  background: #efe9ff;
  color: #5b3fa8;
  border-color: #b9a8f0;
}

.aikc-hwd-meta {
  font-size: 12px;
  color: #6f7b76;
  background: #f4f7f4;
  border: 1px solid #dde7e1;
  border-radius: 8px;
  padding: 3px 9px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aikc-hwd-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.aikc-hwd-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  color: #26332e;
}

/* 代码全文 */
.aikc-hwd-code {
  margin: 0;
  padding: 14px 16px;
  max-height: 460px;
  overflow: auto;
  background: #16241f;
  color: #e8f3ec;
  border-radius: 12px;
  font: 13px/1.75 'Cascadia Mono', 'Consolas', 'Courier New', monospace;
  white-space: pre;
  tab-size: 4;
  user-select: text;
  cursor: text;
}

/* 文字回答：整段完整显示，不截断（教师批改要看全文） */
.aikc-hwd-code.aikc-hwd-text {
  background: #f6f8f5;
  color: #26332e;
  border: 1px solid #dde7e1;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: none;
  overflow: visible;
}

/* 其他回答 */
.aikc-hwd-qa {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  font-size: 13px;
}

.aikc-hwd-qa dt {
  font-weight: 700;
  color: #4a5b53;
}

.aikc-hwd-qa dd {
  margin: 0;
  color: #26332e;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 附件网格（图片直接预览，完整图） */
.aikc-hwd-atts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.aikc-hwd-att {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1.5px solid #dde7e1;
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  color: #26332e;
  transition: transform .12s ease, box-shadow .12s ease;
}

.aikc-hwd-att:hover {
  transform: translateY(-2px);
  box-shadow: 3px 4px 0 #26332e;
}

.aikc-hwd-att img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
  background: #f4f7f4;
  display: block;
}

.aikc-hwd-att small {
  font-size: 12px;
  color: #6f7b76;
  word-break: break-all;
  line-height: 1.4;
}

.aikc-hwd-att.aikc-hwd-file {
  align-items: center;
  justify-content: center;
  min-height: 92px;
  text-align: center;
}

.aikc-hwd-file-icon {
  font-size: 30px;
  line-height: 1;
}

.aikc-hwd-loading,
.aikc-hwd-empty {
  margin: 0;
  font-size: 13px;
  color: #6f7b76;
}

.aikc-hwd-feedback {
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: #eef7f1;
  border: 1px solid #cfe6d8;
  font-size: 13px;
  color: #1f5c39;
  white-space: pre-wrap;
}

/* ② 作业描述：富文本 HTML 修复后的排版 */
.aikc-hwd-rich {
  white-space: normal;
  line-height: 1.75;
  font-size: 14px;
  color: #4a5b53;
}

.aikc-hwd-rich img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 6px 0;
}

.aikc-hwd-rich a {
  color: #1b5f8f;
  text-decoration: underline;
}

.aikc-hwd-rich table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}

.aikc-hwd-rich td,
.aikc-hwd-rich th {
  border: 1px solid #dde7e1;
  padding: 6px 9px;
  font-size: 13px;
}

.aikc-hwd-rich pre,
.aikc-hwd-rich code {
  background: #f4f7f4;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 13px;
}

/* ============================================================
   ③ 学生端 · 提交语言切换（Python / C++）
   ============================================================ */
.aikc-hw-lang-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 12px 16px;
  border: 2px solid #26332e;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff9e8 0%, #fdf3d6 100%);
  box-shadow: 3px 4px 0 #26332e;
}

.aikc-hw-lang-title {
  font-size: 13px;
  font-weight: 800;
  color: #26332e;
  margin-right: 2px;
}

.aikc-hw-lang-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 18px;
  border: 2px solid #26332e;
  border-radius: 999px;
  background: #fff;
  color: #26332e;
  transition: transform .12s ease, background .12s ease;
  min-height: 40px;
}

.aikc-hw-lang-btn:hover {
  transform: translateY(-1px);
}

.aikc-hw-lang-btn.active {
  background: #f6ad2f;
  box-shadow: inset 0 0 0 2px #fff;
}

.aikc-hw-lang-tip {
  display: block;
  margin: 0 0 14px;
  padding: 0 4px;
  font-size: 12px;
  line-height: 1.7;
  color: #6f7b76;
}

/* 窄屏 */
@media (max-width: 640px) {
  .aikc-hwd-meta-text {
    max-width: 100%;
  }
  .aikc-hwd-atts {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  .aikc-hw-lang-picker {
    padding: 10px 12px;
  }
}

/* ============================================================
   ④ r30 · 未读小圆点（首页模块 + 作业卡右上角）
   ============================================================ */
.homework-card-grid article {
  position: relative;
}

.quest-module .aikc-hw-dot,
.homework-card-grid article .aikc-hw-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ff5a5a;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(255, 90, 90, .35);
  z-index: 6;
  pointer-events: none;
  animation: aikcHwDotPulse 1.6s ease-in-out infinite;
}

@keyframes aikcHwDotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

@media (prefers-reduced-motion: reduce) {
  .quest-module .aikc-hw-dot,
  .homework-card-grid article .aikc-hw-dot {
    animation: none;
  }
}

/* ============================================================
   ⑤ r30 · 学生端「老师已评分」大卡片
   ============================================================ */
.aikc-hwg-card {
  margin: 16px 0 4px;
  padding: 18px 20px;
  border: 2px solid #26332e;
  border-radius: 14px;
  box-shadow: 3px 4px 0 #26332e;
  background: linear-gradient(135deg, #eefaf1 0%, #dff3e7 100%);
}

.aikc-hwg-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.aikc-hwg-title {
  font-size: 18px;
  font-weight: 900;
  color: #1f5c39;
  letter-spacing: .3px;
}

.aikc-hwg-points {
  font-size: 14px;
  font-weight: 900;
  color: #8a5a00;
  background: #ffe9b3;
  border: 1.5px solid #f0c264;
  padding: 3px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.aikc-hwg-feedback {
  margin: 12px 0 2px;
  padding: 12px 14px;
  background: #fff;
  border: 1.5px dashed #bcd9c6;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.9;
  color: #26332e;
  white-space: pre-wrap;
  word-break: break-word;
}

.aikc-hwg-sub {
  display: block;
  margin-top: 9px;
  font-size: 12px;
  color: #6f7b76;
}

/* 等级配色：A 绿 / B 蓝 / C 琥珀 / D 灰紫 */
.aikc-hwg-card.aikc-hwg-a { background: linear-gradient(135deg, #eefaf1 0%, #dff3e7 100%); }
.aikc-hwg-card.aikc-hwg-a .aikc-hwg-title { color: #1f5c39; }
.aikc-hwg-card.aikc-hwg-b { background: linear-gradient(135deg, #e8f2fd 0%, #d8e9fb 100%); }
.aikc-hwg-card.aikc-hwg-b .aikc-hwg-title { color: #1b5f8f; }
.aikc-hwg-card.aikc-hwg-c { background: linear-gradient(135deg, #fff6e0 0%, #fdeec7 100%); }
.aikc-hwg-card.aikc-hwg-c .aikc-hwg-title { color: #8a5a00; }
.aikc-hwg-card.aikc-hwg-d { background: linear-gradient(135deg, #f1eff7 0%, #e6e2f0 100%); }
.aikc-hwg-card.aikc-hwg-d .aikc-hwg-title { color: #5b4a7a; }

/* ============================================================
   ⑥ r30 · 作业描述排版（学生端看得清楚、缩进不省）
   ============================================================ */
.aikc-hw-richbox {
  font-size: 15px;
  font-weight: 500;
  line-height: 2;
  color: #26332e;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fffdf6;
  border: 1.5px solid #e7e0c9;
  border-radius: 12px;
  padding: 12px 15px;
  margin: 10px 0;
}

.aikc-hw-richbox img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 6px 0;
}

/* 列表卡里的预览：限高 + 底部渐隐，点「继续修改」看全文 */
.aikc-hw-richbox.aikc-hw-richbox-preview {
  max-height: 138px;
  overflow: hidden;
  position: relative;
}

.aikc-hw-richbox.aikc-hw-richbox-preview::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 36px;
  background: linear-gradient(180deg, rgba(255, 253, 246, 0), #fffdf6);
}

/* 优先级压过 React 自带的 10px 小字与 82px 限高 */
.homework-card-grid .homework-description-preview.aikc-hw-richbox,
.student-module-page header .rich-content.aikc-hw-richbox {
  font-size: 15px;
  line-height: 2;
}

/* hero 里的完整描述：解除 React 限高，全文展示 */
.student-module-page header .rich-content.aikc-hw-richbox {
  max-height: none;
  overflow: visible;
}

/* ============================================================
   ⑦ r30 · 教师端 · 等级评分面板
   ============================================================ */
.aikc-hwd-grade {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
  padding: 16px 18px;
  border: 2px solid #26332e;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff9e8 0%, #fdf3d6 100%);
  box-shadow: 3px 4px 0 #26332e;
}

.aikc-hwd-grade-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.aikc-hwd-grade-btn {
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 108px;
  padding: 10px 14px;
  border: 2px solid #26332e;
  border-radius: 12px;
  background: #fff;
  color: #26332e;
  transition: transform .12s ease, background .12s ease;
}

.aikc-hwd-grade-btn:hover {
  transform: translateY(-2px);
}

.aikc-hwd-grade-btn strong {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.1;
}

.aikc-hwd-grade-btn small {
  font-size: 12px;
  font-weight: 700;
  color: #4a5b53;
}

.aikc-hwd-grade-btn.active {
  background: #f6ad2f;
  box-shadow: inset 0 0 0 2px #fff;
}

.aikc-hwd-grade-text {
  font: inherit;
  width: 100%;
  min-height: 88px;
  padding: 12px 14px;
  border: 1.5px solid #d9cfae;
  border-radius: 10px;
  background: #fff;
  color: #26332e;
  font-size: 14px;
  line-height: 1.8;
  resize: vertical;
}

.aikc-hwd-grade-text:focus {
  outline: 2px solid #f6ad2f;
  outline-offset: 1px;
}

.aikc-hwd-grade-save {
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  align-self: flex-start;
  padding: 12px 26px;
  border: 2px solid #26332e;
  border-radius: 999px;
  background: #ffd166;
  color: #26332e;
  box-shadow: 2px 3px 0 #26332e;
  transition: transform .12s ease, box-shadow .12s ease;
}

.aikc-hwd-grade-save:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 3px 4px 0 #26332e;
}

.aikc-hwd-grade-save:disabled {
  opacity: .55;
  cursor: default;
}

.aikc-hwd-grade-tip {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #6f7b76;
  min-height: 1em;
}

.aikc-hwd-grade-tip.ok { color: #1f5c39; }
.aikc-hwd-grade-tip.err { color: #b3261e; }

.aikc-hwd-grade-done {
  margin: 0;
  font-size: 13px;
  color: #6f7b76;
}

.aikc-hwd-grade-done.ok {
  color: #1f5c39;
  font-weight: 700;
}

.aikc-hwd-adv-fold {
  font-size: 12px;
  color: #6f7b76;
}

.aikc-hwd-adv-fold summary {
  cursor: pointer;
  user-select: none;
}

/* 原生评分输入框：默认交给等级面板；「高级」展开时恢复 */
.aikc-hwd-row .aikc-hwd-native {
  display: none !important;
}

body.aikc-hwd-adv .aikc-hwd-row .aikc-hwd-native {
  display: block !important;
  width: 100%;
}

/* ============================================================
   ⑧ r31：学生端作业页重排
   · 去掉「完成条件」横幅，评分卡顶到页面最上方（数字 1 的位置）
   · 底部提交区（数字 5）：运行测试面板 + 完成提示条 + 提交按钮
   · 提交成功后弹「提交成功」
   ============================================================ */

/* 评分卡独立在编辑器外面时，撑满并留出间距 */
.student-module-page > .aikc-hwg-card {
  margin: 20px 0 4px;
  width: 100%;
  box-sizing: border-box;
}

/* 运行测试面板 */
.aikc-hw-runtest {
  margin: 18px 0 14px;
  padding: 14px 16px 16px;
  border: 2px solid #cfe0ff;
  border-radius: 14px;
  background: #f6faff;
  box-sizing: border-box;
}

.aikc-hw-rt-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.aikc-hw-rt-head strong {
  font-size: 16px;
  color: #10307a;
}

.aikc-hw-rt-head .aikc-hw-rt-lang {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #2f6bff;
  border-radius: 999px;
  padding: 2px 9px;
}

.aikc-hw-rt-head small {
  font-size: 12px;
  color: #6b7a99;
}

.aikc-hw-rt-label {
  display: block;
  margin-bottom: 10px;
}

.aikc-hw-rt-label > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #33415c;
  margin-bottom: 6px;
}

.aikc-hw-rt-stdin {
  width: 100%;
  box-sizing: border-box;
  min-height: 74px;
  padding: 10px 12px;
  font-family: "Consolas", "Menlo", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.7;
  color: #1d2b45;
  background: #fff;
  border: 1px solid #c9d6ef;
  border-radius: 10px;
  resize: vertical;
}

.aikc-hw-rt-stdin:focus {
  outline: none;
  border-color: #2f6bff;
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.15);
}

.aikc-hw-rt-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.aikc-hw-rt-run {
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2f6bff, #1e4fd8);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(47, 107, 255, 0.28);
}

.aikc-hw-rt-run:disabled {
  opacity: 0.65;
  cursor: progress;
  box-shadow: none;
}

.aikc-hw-rt-status {
  font-size: 13px;
  font-weight: 700;
  color: #6b7a99;
}

.aikc-hw-rt-status.ok { color: #128a4a; }
.aikc-hw-rt-status.err { color: #d92d20; }

.aikc-hw-rt-out {
  margin-top: 12px;
}

.aikc-hw-rt-out:empty { margin-top: 0; }

.aikc-hw-rt-out.ok {
  padding: 12px 14px;
  font-family: "Consolas", "Menlo", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  color: #0f5c33;
  background: #eafaf1;
  border: 1px solid #b7e6cd;
  border-radius: 10px;
}

.aikc-hw-rt-out.err {
  padding: 12px 14px;
  background: #fff5f4;
  border: 1px solid #f5c4bd;
  border-radius: 10px;
}

.aikc-hw-rt-out .aikc-hw-rt-title {
  display: block;
  font-size: 16px;
  color: #b42318;
  margin-bottom: 6px;
}

.aikc-hw-rt-out .aikc-hw-rt-hint {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.8;
  color: #5b3a34;
}

.aikc-hw-rt-out .aikc-hw-rt-cap {
  display: block;
  font-size: 12px;
  color: #7a6a66;
  margin-bottom: 4px;
}

.aikc-hw-rt-out .aikc-hw-rt-pre {
  margin: 0 0 8px;
  padding: 10px 12px;
  max-height: 220px;
  overflow: auto;
  font-family: "Consolas", "Menlo", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  background: #fff;
  border-radius: 8px;
}

.aikc-hw-rt-raw {
  margin-top: 6px;
  font-size: 12px;
  color: #8a6a66;
}

.aikc-hw-rt-raw summary { cursor: pointer; }

.aikc-hw-rt-raw pre {
  margin: 6px 0 0;
  padding: 10px 12px;
  max-height: 200px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  background: #fff;
  border-radius: 8px;
}

/* 提示条在底部时，和提交按钮之间留点呼吸 */
.student-homework-editor > .aikc-hw-editor-tip {
  margin-top: 4px;
}

/* 提交成功弹窗 */
.aikc-hw-ok-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 20, 40, 0.5);
  backdrop-filter: blur(2px);
}

.aikc-hw-ok-modal {
  width: min(420px, 88vw);
  padding: 26px 24px 22px;
  text-align: center;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(12, 20, 40, 0.32);
  animation: aikc-hw-ok-pop 0.22s ease-out;
}

@keyframes aikc-hw-ok-pop {
  from { transform: translateY(14px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .aikc-hw-ok-modal { animation: none; }
}

.aikc-hw-ok-icon {
  font-size: 46px;
  line-height: 1;
  margin-bottom: 10px;
}

.aikc-hw-ok-modal h3 {
  margin: 0 0 8px;
  font-size: 22px;
  color: #128a4a;
}

.aikc-hw-ok-modal p {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.9;
  color: #5b6784;
}

.aikc-hw-ok-modal .aikc-hw-ok-note {
  display: block;
  margin: -8px 0 14px;
  font-size: 12px;
  color: #8a94ab;
}

.aikc-hw-ok-btn {
  padding: 10px 34px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #28a35f, #128a4a);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

/* r31：底部 React 的「老师评分」栏（√ 那一栏）已经搬到顶部，这里兜底不显示 */
.student-homework-editor .previous-feedback[data-aikc-hwg-hide="1"] {
  display: none !important;
}
