/**
 * 章节练习区：白底、分节、仿 Notebook（In [n]），与学生端/教师预览共用。
 * 与 apps/student-desktop/public/jupyter-cells.css 保持内容一致。
 */
.jnb-page {
  --jnb-accent: #4f46e5;
  --jnb-text: #0f172a;
  --jnb-muted: #475569;
  --jnb-border: #dbe4f0;
  --jnb-code-bg: #f8fafc;
  --jnb-prompt: #0d9488;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  color: var(--jnb-text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  max-width: 52rem;
  margin: 0 auto;
  padding: 1.35rem clamp(1rem, 3vw, 1.75rem) 7rem;
  box-sizing: border-box;
  border-radius: 18px;
  border: 1px solid var(--jnb-border);
  box-shadow: 0 24px 70px rgba(79, 70, 229, 0.1);
}

.jnb-chapter-h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #172554;
  border-bottom: 1px solid #c7d2fe;
  padding-bottom: 0.7rem;
}
.jnb-h2 {
  margin: 1.55rem 0 0.75rem;
  font-size: 1.24rem;
  font-weight: 800;
  color: #172554;
}
.jnb-h3 {
  margin: 1.2rem 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 750;
  color: #1e293b;
}
.jnb-h3--ext { margin-top: 1.5rem; }
.jnb-h4 {
  margin: 0.5rem 0 0.45rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
}
.jnb-exercise-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.jnb-exercise-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0.16rem 0.52rem;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
}
.jnb-kp { margin-bottom: 1.5rem; }
.jnb-expected {
  margin: 0.65rem 0 0.75rem;
  padding: 0.65rem 0.8rem;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-left: 4px solid var(--jnb-accent);
  border-radius: 10px;
}
.jnb-expected-h {
  font-size: 0.72rem;
  font-weight: 700;
  color: #1d4ed8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}
.jnb-expected-body {
  font-size: 0.9rem;
  color: #1e3a5f;
  line-height: 1.5;
  white-space: pre-wrap;
}
.jnb-expected-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-top: 0.55rem;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  background: #fff;
}
.jnb-code-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.4rem 0 0.25rem;
  font-size: 0.86rem;
}
.jnb-prompt--code {
  flex: 0 0 3.2rem;
  min-width: 3.2rem;
  text-align: right;
  padding-top: 0.5rem;
  color: var(--jnb-prompt);
  font-weight: 600;
}
.jnb-run-row--top { padding-left: 0.25rem; }
.jnb-pending {
  margin: 0.4rem 0 0.2rem 0.25rem;
  font-size: 0.82rem;
  color: #64748b;
}
.jnb-out--empty .jnb-out-empty {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: #94a3b8;
  font-style: italic;
}
.jnb-md-cell h1, .jnb-md-cell h2, .jnb-md-cell h3, .jnb-md-cell h4 {
  font-size: 1em;
  margin: 0.4em 0;
}

/* 章标题 + 总说明 */
.jnb-hero-title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--jnb-text);
}
.jnb-hero-lead {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--jnb-muted);
  line-height: 1.55;
}

/* 轻提示条（预载、运行环境） */
.jnb-instructions,
.jnb-py-box {
  border: 1px solid var(--jnb-border);
  border-left: 4px solid var(--jnb-accent);
  background: #f8fafc;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin: 0 0 1.25rem;
  font-size: 0.88rem;
  color: #334155;
}
.jnb-py-box strong {
  color: var(--jnb-text);
  font-weight: 600;
}
.jnb-preload-link {
  background: none;
  border: none;
  color: var(--jnb-accent);
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
  padding: 0;
}
.jnb-status-ok {
  color: #15803d;
  font-weight: 500;
}
.jnb-status-err {
  color: #b91c1c;
}

/* 每一大块（对应 published_content 的一个 block）；jnb-surface 为旧名，样式相同 */
.jnb-section,
.jnb-surface {
  margin: 0 0 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--jnb-border);
}
.jnb-section:last-of-type,
.jnb-surface:last-of-type {
  border-bottom: none;
  margin-bottom: 0.5rem;
  padding-bottom: 0;
}

.jnb-sec-h {
  margin: 0 0 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--jnb-muted);
  text-transform: none;
  letter-spacing: 0.02em;
}
.jnb-sec-h strong {
  color: var(--jnb-text);
  font-size: 1.05rem;
  font-weight: 700;
}

/* Markdown 知识 / 题面 */
.jnb-md-cell {
  background: #fff;
  border: 1px solid var(--jnb-border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin: 0.5rem 0 1rem;
  line-height: 1.65;
  color: #1e293b;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.035);
}
.jnb-md-cell p {
  margin: 0.4rem 0;
}
.jnb-md-cell ul,
.jnb-md-cell ol {
  margin: 0.35rem 0;
  padding-left: 1.25rem;
}
.jnb-md-cell h1, .jnb-md-cell h2, .jnb-md-cell h3, .jnb-md-cell h4 {
  font-size: 1rem;
  margin: 0.5rem 0;
}

/* 小标题：引导、扩展、说明文字 */
.jnb-label {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--jnb-text);
}
.jnb-cell-desc {
  margin: 0 0 0.6rem;
  font-size: 0.88rem;
  color: #475569;
}

/* 代码行：In [n]: + 区 */
.jnb-code-cell {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.35rem 0 0.4rem;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.86rem;
}
.jnb-prompt {
  flex: 0 0 auto;
  color: var(--jnb-prompt);
  font-weight: 600;
  padding-top: 0.45rem;
  user-select: none;
  min-width: 4.2rem;
  text-align: right;
  font-size: 0.85rem;
}
.jnb-prompt--muted {
  color: #94a3b8;
  min-width: 3.5rem;
  font-size: 0.8rem;
  font-weight: 500;
}
.jnb-code-col {
  flex: 1;
  min-width: 0;
}

/* 备用：独立提示区。当前基础练习主交互使用下方的同框底纹。 */
.jnb-code-hint-panel {
  margin: 0 0 0.5rem 0;
  padding: 0.55rem 0.7rem;
  box-sizing: border-box;
  background: var(--jnb-code-bg);
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font: inherit;
  line-height: 1.45;
}
.jnb-code-hint-label {
  color: #b91c1c;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
}
.jnb-code-hint-code {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #94a3b8;
  font: inherit;
  line-height: 1.45;
}

/* 基础练习：红字提示 + 灰字参考与输入区在同一个框；聚焦或输入后由 React 隐藏底纹。 */
.jnb-code-col--backdrop {
  position: relative;
  background: var(--jnb-code-bg);
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-sizing: border-box;
}
.jnb-code-backdrop {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 0;
  min-height: 5rem;
  padding: 0.55rem 0.7rem;
  box-sizing: border-box;
  pointer-events: none;
  user-select: none;
  font: inherit;
  line-height: 1.45;
}
.jnb-code-backdrop-label {
  color: #b91c1c;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
}
.jnb-code-backdrop-code {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #94a3b8;
  font: inherit;
  line-height: 1.45;
}
textarea.jnb-input.jnb-input--backdrop-on {
  position: relative;
  z-index: 1;
  background: transparent !important;
  border: none;
  box-shadow: none;
  border-radius: 12px;
}
textarea.jnb-input.jnb-input--backdrop-on:focus {
  outline: none;
  box-shadow: none;
}

textarea.jnb-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 5rem;
  margin: 0;
  padding: 0.65rem 0.8rem;
  background: var(--jnb-code-bg);
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  color: #0f172a;
  font: inherit;
  line-height: 1.45;
  resize: vertical;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
textarea.jnb-input:focus {
  outline: none;
  border-color: var(--jnb-accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.16);
}

pre.jnb-input-ro {
  margin: 0;
  min-height: 2.5rem;
  padding: 0.55rem 0.7rem;
  background: #f1f5f9;
  border: 1px solid var(--jnb-border);
  border-radius: 4px;
  color: #0f172a;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
  line-height: 1.45;
}

/* 运行行 */
.jnb-run-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0.55rem 0 0.25rem;
  padding: 0.15rem 0 0.2rem 0.25rem;
  padding-left: 4.9rem;
  font-family: system-ui, sans-serif;
  font-size: 0.88rem;
}
.jnb-run-row button {
  background: var(--jnb-accent);
  border: 1px solid var(--jnb-accent);
  border-radius: 10px;
  padding: 0.46rem 1rem;
  cursor: pointer;
  font: inherit;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.18);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.jnb-run-row button:hover {
  background: #4338ca;
  border-color: #4338ca;
  box-shadow: 0 10px 22px rgba(79, 70, 229, 0.22);
}
.jnb-run-row button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.jnb-run-row button.jnb-btn-secondary {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #475569;
  font-weight: 650;
  box-shadow: none;
}
.jnb-run-row button.jnb-btn-secondary:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

/* 过关说明 */
.jnb-hint {
  color: #64748b;
  font-size: 0.8rem;
  margin: 0.35rem 0 0.2rem;
  padding-left: 4.9rem;
  line-height: 1.5;
  font-family: system-ui, sans-serif;
}
.jnb-hint code {
  background: #f1f5f9;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.78rem;
  color: #334155;
}

.jnb-ok { color: #15803d; font-weight: 500; }
.jnb-warn { color: #b45309; }
.jnb-err { color: #b91c1c; }

/* 单次运行结果（Out：stdout / 异常，仿 Notebook 输出区） */
.jnb-out {
  margin: 0.5rem 0 0.7rem;
  padding: 0.55rem 0.75rem 0.65rem 4.7rem;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.45;
  border-left: 2px solid #c7d2fe;
  margin-left: 0.15rem;
}
.jnb-out-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--jnb-muted);
  margin-bottom: 0.15rem;
}
.jnb-out pre.jnb-out-text {
  margin: 0.2rem 0 0;
  padding: 0.45rem 0.6rem;
  background: #f8fafc;
  border: 1px solid var(--jnb-border);
  border-radius: 10px;
  font: 0.8rem/1.45 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color: #0f172a;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 10rem;
  overflow: auto;
}
.jnb-out pre.jnb-out-text--bad {
  background: #fef2f2;
  border-color: #fecaca;
  color: #7f1d1d;
}

/* 判题消息栏 */
.jnb-msg {
  margin: 0.5rem 0 0.5rem 4.7rem;
  padding: 0.55rem 0.7rem 0.6rem;
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.5;
  border: 1px solid var(--jnb-border);
  font-family: system-ui, sans-serif;
}
.jnb-msg-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}
.jnb-msg-body {
  color: #1e293b;
}
.jnb-msg--ok {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}
.jnb-msg--ok .jnb-msg-label { color: #047857; }
.jnb-msg--warn {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #78350f;
}
.jnb-msg--warn .jnb-msg-label { color: #b45309; }
.jnb-msg--err {
  background: #fef2f2;
  border-color: #fecaca;
  color: #7f1d1d;
}
.jnb-msg--err .jnb-msg-label { color: #b91c1c; }

/* 标准答案参考（教师发布） */
.jnb-ref {
  margin: 0.65rem 0 0.4rem 4.2rem;
  padding: 0.5rem 0.65rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
}
.jnb-ref-h {
  font-size: 0.72rem;
  font-weight: 600;
  color: #166534;
  margin-bottom: 0.35rem;
}
.jnb-ref-pre {
  margin: 0;
  font: 0.8rem/1.45 ui-monospace, Menlo, Consolas, monospace;
  color: #14532d;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 12rem;
  overflow: auto;
}

/* 本章完成区 */
.jnb-footer-actions {
  margin-top: 1.75rem;
  padding: 1rem;
  border-top: 1px solid var(--jnb-border);
  border-radius: 16px;
  background: #f8fafc;
}
.jnb-footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}
.jnb-footer-btns-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  flex: 1 1 auto;
  min-width: 0;
}
.jnb-footer-back {
  margin-left: auto;
}
.jnb-footer-actions button {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.55rem 1.15rem;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(22, 163, 74, 0.18);
}
.jnb-footer-actions button.jnb-btn-secondary {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  box-shadow: none;
}
.jnb-footer-actions button.jnb-btn-secondary:hover {
  background: #e2e8f0;
}
.jnb-footer-actions button:not(.jnb-btn-secondary):hover {
  background: #15803d;
}
.jnb-footer-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
.jnb-footer-hintline {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  color: var(--jnb-muted);
  width: 100%;
}
.jnb-footer-msg {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: #1e3a5f;
}
.jnb-footer-err {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: #9f1239;
}

/* 键帽（与参考图一致，若 HTML 中用到 <kbd>） */
kbd,
.jnb-kbd {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  font: 0.8rem ui-monospace, monospace;
  color: #334155;
  box-shadow: 0 1px 0 #e2e8f0;
}

/* 嵌在 App 深色背景中：外框白底小卡片感（学生/教师同规则） */
.jnb-student-embed,
.jnb-teacher-embed,
.teacher-jnb {
  background: transparent;
  border: none;
  border-radius: 18px;
  padding: 0;
  margin-top: 0.5rem;
  overflow: visible;
}
.jnb-student-embed .jnb-page,
.jnb-teacher-embed .jnb-page,
.teacher-jnb .jnb-page {
  border: none;
  margin: 0;
  max-width: none;
  padding: 1.25rem clamp(1rem, 3vw, 1.75rem) 7rem;
  border-radius: 18px;
}

@media (max-width: 640px) {
  .jnb-page,
  .jnb-student-embed .jnb-page,
  .jnb-teacher-embed .jnb-page,
  .teacher-jnb .jnb-page {
    padding-bottom: 8.5rem;
  }

  .jnb-code-row {
    gap: 0.4rem;
  }

  .jnb-prompt--code,
  .jnb-prompt {
    flex-basis: 2.6rem;
    min-width: 2.6rem;
    font-size: 0.78rem;
  }

  .jnb-run-row,
  .jnb-hint,
  .jnb-out,
  .jnb-msg {
    padding-left: 3.2rem;
    margin-left: 0;
  }

  .jnb-footer-row,
  .jnb-footer-btns-main {
    align-items: stretch;
    flex-direction: column;
  }

  .jnb-footer-back {
    margin-left: 0;
  }

  .jnb-footer-actions button {
    width: 100%;
  }
}
.jnb-teacher-banner {
  font-size: 0.8rem;
  color: #64748b;
  margin: 0 0 0.5rem 0.25rem;
}

/* 小节标题（如「第 n 块」可与 .jnb-sec-h 并用） */
.jnb-block-title {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--jnb-muted);
  letter-spacing: 0.02em;
}
.jnb-block-title strong {
  color: var(--jnb-text);
  font-size: 1.05rem;
  font-weight: 700;
}
