/* ============================================================
   漏斗编程教学平台 —— 样式表
   浅色主题 · 中文界面 · 紧凑工具栏
   ============================================================ */

:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --border: #e3e6ec;
  --border-strong: #cdd3dd;
  --text: #1f2328;
  --text-2: #5c6672;
  --text-3: #8b94a3;
  --primary: #2f6fed;
  --primary-dark: #1f57c9;
  --primary-soft: #eaf1fe;
  --ac: #16a34a;
  --ac-soft: #e7f7ed;
  --wa: #dc2626;
  --wa-soft: #fdecec;
  --tle: #d97706;
  --tle-soft: #fdf3e3;
  --re: #7c3aed;
  --re-soft: #f3ecfe;
  --ce: #64748b;
  --ce-soft: #eef1f5;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------------------------------------------------- 顶栏 */

.topbar {
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  flex: 0 0 auto;
}

.topbar .brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.topbar .brand .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.topbar .crumb {
  color: var(--text-2);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .spacer { flex: 1 1 auto; }

.topbar .who {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

.topbar .who b { color: var(--text); font-weight: 600; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}

.btn:hover { background: #f7f8fa; border-color: #b9c0cc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn.success {
  background: var(--ac);
  border-color: var(--ac);
  color: #fff;
  font-weight: 600;
}
.btn.success:hover { filter: brightness(.94); }

.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: #eef1f5; color: var(--text); }

.btn.danger { color: var(--wa); border-color: #f0c4c4; background: #fff; }
.btn.danger:hover { background: var(--wa-soft); }

.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.block { width: 100%; }

/* ---------------------------------------------------- 卡片 / 面板 */

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

.card + .card { margin-top: 14px; }

.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 16px 60px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-sub { color: var(--text-2); font-size: 13px; margin: 0 0 18px; }

/* ---------------------------------------------------- 徽章 */

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  font-family: var(--mono);
}

.badge.AC  { background: var(--ac-soft);  color: var(--ac); }
.badge.WA  { background: var(--wa-soft);  color: var(--wa); }
.badge.TLE { background: var(--tle-soft); color: var(--tle); }
.badge.RE  { background: var(--re-soft);  color: var(--re); }
.badge.CE  { background: var(--ce-soft);  color: var(--ce); }
.badge.OLE { background: var(--tle-soft); color: var(--tle); }
.badge.PA  { background: var(--primary-soft); color: var(--primary); }
.badge.IE  { background: var(--ce-soft);  color: var(--ce); }

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 11px;
  background: #eef1f5;
  color: var(--text-2);
  white-space: nowrap;
}

.tag.blue { background: var(--primary-soft); color: var(--primary-dark); }
.tag.green { background: var(--ac-soft); color: var(--ac); }
.tag.amber { background: var(--tle-soft); color: var(--tle); }

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

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

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

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

table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #fafbfd; }
table.tbl td.num { font-family: var(--mono); text-align: right; }
table.tbl td.mono { font-family: var(--mono); }

/* ---------------------------------------------------- 表单 */

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

input[type=text], input[type=password], input[type=number], input[type=datetime-local],
select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea { resize: vertical; min-height: 70px; font-family: var(--mono); font-size: 12.5px; }

.hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

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

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef3fb 0%, #f6f8fb 55%, #eef7f1 100%);
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 30px 28px 26px;
}

.login-box h1 {
  font-size: 19px;
  margin: 0 0 3px;
  text-align: center;
}

.login-box .sub {
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
  margin-bottom: 22px;
}

.login-err {
  background: var(--wa-soft);
  color: var(--wa);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 12.5px;
  margin-bottom: 13px;
}

/* ---------------------------------------------------- 做题页三栏 */

.workbench {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 52px); /* 52 = 顶栏高度，否则底部会被切掉一截 */
  overflow: hidden;
}

.wb-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.wb-left {
  width: 330px;
  flex: 0 0 auto;
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
  padding: 16px;
}

.wb-center {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  position: relative; /* 调试工具条浮在它里面 */
}

.wb-right {
  width: 430px;
  flex: 0 0 auto;
  border-left: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.wb-toolbar {
  height: 44px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.wb-editor {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
  display: flex;
}

/* ---------------------------------------------------- 程序输入（input() 的值）

   学生最容易踩的坑：题目要输入，但不知道在哪填。
   所以这一行会在「代码里用了 input() 而框里是空的」时变成橙色高亮。 */

.stdin-row {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 12px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}

.stdin-label {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-2);
  line-height: 28px;
  white-space: nowrap;
}

.stdin-box {
  flex: 1 1 0;      /* 基准 0：不管 textarea 的 cols 是多少都填满剩余宽度 */
  width: 100%;
  min-width: 0;
  min-height: 28px;
  max-height: 96px;
  padding: 4px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  resize: none;
  outline: none;
  white-space: pre;
  overflow: auto;
}

.stdin-box::placeholder { font-family: inherit; color: var(--text-3); }
.stdin-box:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* 需要输入但还没填 —— 橙色提醒 */
.stdin-row.need .stdin-label { color: #c96a10; font-weight: 600; }
.stdin-row.need .stdin-box {
  border-color: #f0a95c;
  background: #fffbf3;
  box-shadow: 0 0 0 3px rgba(240, 169, 92, .16);
}
.stdin-row.need .stdin-box::placeholder { color: #c96a10; }

/* 点了运行却没填 —— 闪三下，眼睛一定会看到 */
.stdin-box.flash { animation: stdinFlash .42s ease-in-out 3; }
@keyframes stdinFlash {
  0%, 100% { background: #fffbf3; }
  50% { background: #ffe3ba; }
}

.stdin-hint {
  flex: 0 0 auto;
  font-size: 11.5px;
  line-height: 28px;
  color: var(--text-3);
  white-space: nowrap;
}
.stdin-row.need .stdin-hint { color: #c96a10; }

/* 运行出错时的中文指引（比如 EOFError → 告诉他在哪填输入） */
.run-tip {
  margin: 0 14px 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--tle-soft);
  border: 1px solid #f2d7ac;
  color: #8a5a10;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
}

/* ============================================================
   编辑器（CodeMirror 6 封装，public/js/editor.js）
   .ed
     ├ .ed-bar   ← 文件标签 + 工具（字号/主题/全屏）
     ├ .ed-main  ← CodeMirror 挂载点
     └ .ed-foot  ← 行号列号 · 语法检查状态
   ============================================================ */

.ed {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  background: var(--panel);
}

.ed-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 36px;
  padding: 0 6px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  overflow: hidden;
}

.ed-tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.ed-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  flex: 0 0 auto;
}
.ed-tab:hover { color: var(--text); background: rgba(47, 111, 237, .05); }
.ed-tab.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
  background: var(--panel);
  font-weight: 600;
}
.ed-tab-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

/* 该文件有语法错误时的红点 */
.ed-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wa);
  flex: 0 0 auto;
}

.ed-tab-x {
  font-style: normal;
  font-size: 13px;
  line-height: 1;
  color: var(--text-3);
  padding: 0 1px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity .12s;
}
.ed-tab:hover .ed-tab-x { opacity: 1; }
.ed-tab-x:hover { background: var(--wa-soft); color: var(--wa); }

.ed-add {
  flex: 0 0 auto;
  width: 24px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  margin: 4px 2px;
}
.ed-add:hover { background: var(--primary-soft); color: var(--primary); }

.ed-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 3px;
}

.ed-select {
  height: 24px;
  font-size: 11.5px;
  padding: 0 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel);
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--mono);
}

.ed-ico {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.ed-ico:hover { color: var(--primary); border-color: var(--primary-soft); background: var(--primary-soft); }

.ed-main {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.ed-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 24px;
  padding: 0 10px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 11.5px;
  color: var(--text-3);
  font-family: var(--mono);
}
.ed-lint.ok { color: var(--ac); }
.ed-lint.err { color: var(--wa); }
.ed-lint.warn { color: var(--tle); }
.ed-entry { color: var(--text-3); }

/* 全屏 */
.ed.ed-full {
  position: fixed;
  inset: 0;
  z-index: 900;
  border-radius: 0;
  box-shadow: 0 0 0 100vmax rgba(16, 24, 40, .28);
}
body.ed-full-lock { overflow: hidden; }

/* 只读（教师看学生代码） */
.ed.ed-readonly .ed-main { background: var(--panel-2); }

/* 只读时不要「当前行」底色：它会盖在选区上层，让那一行看着没被选中 */
/* 只在「没有整篇全选」时去掉当前行底色：全选时要靠行底色铺满整行 */
.ed-readonly .cm-scroller:not(.cm-all-selected) .cm-activeLine,
.ed-readonly .cm-scroller:not(.cm-all-selected) .cm-activeLineGutter {
  background: transparent !important;
}

/* 弹窗内的编辑器槽位：必须给显式高度，否则 flex 链断了会塌成 0 */
.ed-slot {
  display: flex;
  height: 320px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.ed-slot-sm { height: 158px; }
.ed-slot-lg { height: 300px; }
.ed-slot .ed { border-radius: 0; }
.ed-slot .ed-bar { height: 30px; }
.ed-slot .ed-foot { height: 20px; font-size: 11px; }

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

.prob-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.prob-desc {
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
}

.prob-desc pre, .prob-desc code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: #f2f4f7;
  border-radius: 4px;
}

.prob-desc pre {
  padding: 10px 12px;
  overflow-x: auto;
  border: 1px solid var(--border);
  line-height: 1.6;
}

.prob-desc code { padding: 1px 5px; }
.prob-desc pre code { padding: 0; background: none; font-size: 12.5px; }
.prob-desc strong { color: #111; }
.prob-desc p { margin: 0 0 10px; }
.prob-desc ul, .prob-desc ol { padding-left: 20px; margin: 0 0 10px; }

.hr { height: 1px; background: var(--border); margin: 14px 0; }

.sec-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: none;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------------------------------------------------- 画布区 */

.canvas-wrap {
  position: relative;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  height: 300px;
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 画布上的三块浮动层：平时半透明，鼠标移上去变实。
   这样即使图形调得很大、正好从控件底下穿过，也不会被完全挡掉。 */
.canvas-badge,
.canvas-bar,
.canvas-zoom {
  opacity: .62;
  transition: opacity .15s;
}
.canvas-badge:hover,
.canvas-bar:hover,
.canvas-zoom:hover { opacity: 1; }

.canvas-bar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  backdrop-filter: blur(4px);
}

.canvas-bar .btn { height: 24px; padding: 0 8px; font-size: 11.5px; border: none; }

.canvas-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  font-size: 11px;
  color: var(--text-3);
  background: rgba(255,255,255,.92);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* 画布缩放：− 100% +（右下角，点百分比复位） */
.canvas-zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 1px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  backdrop-filter: blur(4px);
}

.canvas-zoom .zbtn {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1;
  border-radius: 4px;
  cursor: pointer;
}
.canvas-zoom .zbtn:hover { background: var(--primary-soft); color: var(--primary); }

.canvas-zoom .zval {
  min-width: 42px;
  height: 22px;
  padding: 0 3px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  border-radius: 4px;
}
.canvas-zoom .zval:hover { background: var(--primary-soft); color: var(--primary); }
.canvas-zoom .zval.off { color: var(--primary-dark); font-weight: 600; }

.output-pane {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  flex: 0 0 auto;
}

.tabs .tab {
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  user-select: none;
}

.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.tab-panels { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.console {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 12px 14px;
  margin: 0;
  color: var(--text);
}

.console.empty { color: var(--text-3); font-family: inherit; font-size: 12.5px; }
.console.err { color: var(--wa); }

/* 测试点列表 */
.case-list { padding: 8px; }

.case-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 7px;
  overflow: hidden;
}

.case-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  cursor: pointer;
  background: var(--panel-2);
}

.case-top:hover { background: #f1f4f8; }
.case-top .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-top .sec { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; }

.case-body {
  padding: 9px 11px;
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.case-body .row { margin-bottom: 7px; }
.case-body .row:last-child { margin-bottom: 0; }
.case-body .lbl { color: var(--text-3); font-size: 11px; margin-bottom: 2px; }
.case-body pre {
  font-family: var(--mono);
  font-size: 11.5px;
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  margin: 0;
  max-height: 130px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.case-body pre.bad { background: var(--wa-soft); border-color: #f3d0d0; color: #a01818; }

.compare-mini { display: flex; gap: 8px; margin-top: 7px; }
.compare-mini > div { flex: 1; min-width: 0; }
.compare-mini .lbl { font-size: 11px; color: var(--text-3); margin-bottom: 3px; }
.compare-mini canvas {
  width: 100%;
  height: 110px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  display: block;
}

/* 结果横幅 */
.result-banner {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.result-banner .big { font-size: 22px; font-weight: 800; font-family: var(--mono); }
.result-banner .info { flex: 1; min-width: 0; }
.result-banner .line1 { font-size: 13.5px; font-weight: 600; }
.result-banner .line2 { font-size: 12px; color: var(--text-2); margin-top: 1px; }

/* ---------------------------------------------------- 列表卡片 */

.assignment-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  transition: border-color .12s, box-shadow .12s;
}

.assignment-card:hover { border-color: #c3d2ee; box-shadow: 0 3px 10px rgba(47,111,237,.08); }

.assignment-card .left { flex: 1; min-width: 0; }
.assignment-card .t { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.assignment-card .d { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assignment-card .metrics { display: flex; gap: 20px; text-align: center; }
.assignment-card .metrics .m .v { font-family: var(--mono); font-weight: 700; font-size: 16px; }
.assignment-card .metrics .m .k { font-size: 11px; color: var(--text-3); }

.progress {
  height: 6px;
  background: #eceff4;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}
.progress > i { display: block; height: 100%; background: var(--ac); border-radius: 3px; transition: width .3s; }

/* 题目行 */
.problem-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.problem-row:last-child { border-bottom: none; }
.problem-row:hover { background: #fafbfd; }
.problem-row .idx {
  width: 26px; height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #eef1f5;
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.problem-row.solved .idx { background: var(--ac-soft); color: var(--ac); }
.problem-row .ttl { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.problem-row .sc { font-family: var(--mono); font-size: 13px; color: var(--text-2); }

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

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-3);
}

.empty-state .icon { font-size: 34px; margin-bottom: 10px; opacity: .5; }
.empty-state .t { font-size: 14px; margin-bottom: 4px; color: var(--text-2); }

/* ---------------------------------------------------- 模态框 */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  overflow: hidden;
}

.modal.wide { max-width: 1140px; }

/* 出题弹窗的左右两栏布局：左＝基本信息，右＝标程与测试点 */
.pe-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; }
.pe-col { min-width: 0; }
.pe-grid .hr { margin: 0 0 14px; }
@media (max-width: 1120px) { .pe-grid { grid-template-columns: 1fr; } }

.modal-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
}

.modal-head .spacer { flex: 1; }
.modal-body { padding: 20px; max-height: 74vh; overflow-y: auto; }

.modal-foot {
  padding: 13px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  background: var(--panel-2);
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ---------------------------------------------------- 提示条 */

.toast-wrap {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: #1f2328;
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .18s ease-out;
  max-width: 76vw;
}

.toast.ok { background: #14793a; }
.toast.err { background: #b91c1c; }

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

/* ---------------------------------------------------- 加载动画 */

.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}

.spinner.dark { border-color: rgba(0,0,0,.18); border-top-color: var(--primary); }

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

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.72);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-2);
  z-index: 10;
  backdrop-filter: blur(1px);
}

/* ============================================================
   分步调试（public/js/debug.js）
   .dbg-bar      ← 浮在代码区顶部的单步工具条（可拖动）
   .dbg-drawer   ← 底部「输出 + 观测」抽屉
   .cm-bp-*      ← 行号左边的断点红点
   .cm-debug-line← 当前停在哪一行（黄底 + 左侧橙条）
   ============================================================ */

/* 工具栏上的「调试」按钮：白底橙边，和运行 / 提交区分开 */
.btn.debug {
  background: #fff;
  border-color: #f0a95c;
  color: #c96a10;
  font-weight: 600;
}
.btn.debug:hover { background: #fff8ef; border-color: #e2913a; color: #a8570a; }
.btn.debug.on {
  background: #fff1e0;
  border-color: #e2913a;
  color: #a8570a;
  box-shadow: 0 0 0 3px rgba(240, 169, 92, .2);
}

/* ---------------------------------------------------- 单步工具条 */

.dbg-bar {
  position: absolute;
  top: 82px;            /* 工具栏 44 + 编辑器标签栏 36 + 2 */
  right: 16px;          /* 靠右上角：尽量别压住行首的代码 */
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 7px 5px 4px;
  background: #fff;
  border: 1px solid #dfe3ea;
  border-radius: 9px;
  box-shadow: 0 6px 20px rgba(16, 24, 40, .16);
  z-index: 40;
  user-select: none;
  opacity: .97;
}
.dbg-bar:hover { opacity: 1; }

.dbg-bar[hidden] { display: none; }
.dbg-bar.busy { pointer-events: none; opacity: .6; }

.dbg-drag {
  width: 14px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c2c8d2;
  font-size: 12px;
  cursor: grab;
  border-radius: 4px;
}
.dbg-drag:hover { color: #8b94a3; background: #f2f4f7; }
.dbg-drag:active { cursor: grabbing; }

.dbg-btn {
  width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #4b5563;
  cursor: pointer;
}
.dbg-btn:hover { background: #eef1f5; color: #1f2328; }
.dbg-btn:active { transform: translateY(1px); }
.dbg-btn.play { color: #16a34a; }
.dbg-btn.play:hover { background: var(--ac-soft); }
.dbg-btn.stop { color: #dc2626; }
.dbg-btn.stop:hover { background: var(--wa-soft); }

.dbg-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 3px;
}

/* ---------------------------------------------------- 底部抽屉 */

.dbg-drawer {
  flex: 0 0 auto;
  height: 208px;
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  min-height: 0;
  border-top: 1px solid var(--border);
  background: var(--panel);
  position: relative;
}

.dbg-drawer[hidden] { display: none; }

.dbg-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
}
.dbg-pane.grow { border-right: none; }

.dbg-pane-head {
  flex: 0 0 auto;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}

.dbg-badge {
  max-width: 62%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 1px 6px;
  border-radius: 4px;
  background: #eef1f5;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
}

.dbg-out {
  flex: 1 1 auto;
  margin: 0;
  padding: 9px 12px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.dbg-vars {
  flex: 1 1 auto;
  overflow: auto;
  padding: 2px 0 10px;
  font-family: var(--mono);
  font-size: 12px;
}

.dbg-group { border-bottom: 1px solid #f1f3f6; }
.dbg-group:last-child { border-bottom: none; }

.dbg-group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.dbg-group-head:hover { background: #f7f8fa; }
.dbg-group-head .caret { width: 9px; font-size: 9px; color: var(--text-3); }

.dbg-count {
  padding: 0 6px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10.5px;
  font-weight: 400;
  line-height: 15px;
}

.dbg-group-body { padding: 0 12px 6px 26px; }

.dbg-var {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 2px 0;
  line-height: 1.55;
}
.dbg-var .n { color: #7c3aed; }
.dbg-var .eq { color: var(--text-3); }
.dbg-var .v { color: #b45309; word-break: break-all; }

.dbg-empty { padding: 5px 0; color: var(--text-3); font-size: 11.5px; }

.dbg-close {
  position: absolute;
  top: 5px;
  right: 8px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-3);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.dbg-close:hover { background: #eef1f5; color: var(--text); }

/* ---------------------------------------------------- 编辑器里的调试标记 */

/* 断点槽：14px 窄条，点一下切换 */
.cm-bp-gutter { width: 14px; cursor: pointer; }
.cm-bp-gutter .cm-gutterElement {
  width: 14px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* 悬停提示：淡淡的红点，告诉学生"这里能点" */
.cm-bp-gutter .cm-gutterElement:hover::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: rgba(229, 72, 77, .26);
}

.cm-bp-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e5484d;
  box-shadow: 0 0 0 2px rgba(229, 72, 77, .16);
}

/* 当前执行行：比 .cm-activeLine 多一个类，能压住它的底色 */
.cm-line.cm-debug-line {
  background: #fff8dc;
  box-shadow: inset 2px 0 0 #f0a95c;
}

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

@media (max-width: 1180px) {
  .wb-left { width: 280px; }
  .wb-right { width: 360px; }
}

@media (max-width: 940px) {
  .wb-body { flex-direction: column; overflow-y: auto; }
  .wb-left, .wb-center, .wb-right { width: 100%; flex: 0 0 auto; }
  .wb-center { height: auto; }
  .wb-editor { height: 380px; }
  .wb-right { border-left: none; border-top: 1px solid var(--border); }
  .workbench { height: auto; overflow: visible; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .dbg-drawer { height: 180px; grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .dbg-pane { border-right: none; border-bottom: 1px solid var(--border); }
}
