/* Mathematica 12 网页复刻 · 笔记本与单元格（notebook.css）
 * 真机微测（1920×1032 应用区，2026-11-19 采）：
 *   - 笔记本区 y=43..1014；首单元格空态为 x=40..1880 的 1px 插入线（#BFBFBF），左侧 "+" 把手 16×16。
 *   - 提示符 "In[1]:=" 文本起点 x=34，正文起点 x=67；行距约 26px；提示符色 #3E6A96。
 *   - 单元格括号在右缘（输入框线 x≈1911，输出框线内缩一级）。
 */

.notebook {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--notebook-bg);
  padding: 0;
  font-family: var(--cell-font);
}

.notebook-content {
  position: relative;
  padding: 0 0 40px 0;
  min-height: 100%;
}

.insert-handle {
  position: absolute;
  left: 13px;
  top: 0;
  z-index: 5;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid #cccccc;
  border-radius: 3px;
  background: #fbfbfb;
  color: #b3b3b3;
  font: 12px/14px var(--ui-font);
  text-align: center;
  cursor: pointer;
}
.insert-handle:hover { background: #eef5fc; color: #6b9ac4; border-color: #9fc4e8; }

.cell {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 3px 14px 3px 34px;
  min-height: 25px;
}

.cell-prompt {
  flex: 0 0 30px;
  width: 30px;
  color: var(--prompt);
  font-family: var(--cell-font);
  font-size: 10px;
  line-height: 19px;
  text-align: left;
  user-select: none;
  padding-top: 2px;
  white-space: nowrap;
  overflow: visible;
}

.cell-body {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 3px;
}

.cell-content {
  min-height: 19px;
  outline: none;
  color: #000000;
  font-family: var(--cell-font);
  font-size: 14px;
  line-height: 19px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  caret-color: #000000;
}

/* 空态：隐藏提示符，显示整行插入线（对齐真机空白笔记本） */
.cell.is-empty .cell-prompt { visibility: hidden; }
.cell.is-empty .cell-body::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 26px;
  top: 8px;
  height: 1px;
  background: var(--cell-line);
}
.cell.is-empty.is-focused { background: transparent; }
.cell.is-empty.is-focused .cell-prompt { visibility: visible; }
.cell.is-empty.is-focused .cell-body::before { content: none; }

/* 单元格右侧括号 */
.cell-bracket {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 12px;
  pointer-events: none;
  opacity: 0;
}
.cell.has-bracket .cell-bracket { opacity: 1; }
.cell[data-cell-type="input"] .cell-bracket { right: 6px; }
.cell[data-cell-type="output"] .cell-bracket { right: 19px; }
.cell-bracket::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 2px;
  background: var(--bracket);
}
.cell-bracket::after {
  content: "";
  position: absolute;
  top: 0;
  right: -3px;
  width: 8px;
  height: 8px;
  background: var(--bracket);
}

/* 输出单元格 */
.cell[data-cell-type="output"] { min-height: 25px; }
.cell-output-text {
  color: #000000;
  font-family: var(--cell-font);
  font-size: 13px;
  line-height: 19px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.cell-output-text.is-unevaluated { color: #333333; }
.cell-output-text.is-error { color: #8b1a1a; font-size: 12px; }
.cell-output-graphics { margin: 2px 0 4px 0; }
.cell-output-graphics canvas { display: block; }

/* 输出单元格的提示符（Out[n]=） */
.cell[data-cell-type="output"] .cell-prompt { padding-top: 1px; }

/* 悬停高亮 */
.cell:hover::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: rgba(204, 230, 255, 0.10);
  pointer-events: none;
}

/* 选中单元格 */
.cell.is-selected { background: #eaf4ff; }
.cell.is-selected .cell-bracket::before { background: #5a5a5a; }
.cell.is-selected .cell-bracket::after { background: #5a5a5a; }

/* 闪烁光标（聚焦的空单元格） */
.cell.is-focused .cell-content:empty::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 15px;
  margin-top: 2px;
  background: #000000;
  vertical-align: text-bottom;
  animation: mma-caret 1.06s steps(1) infinite;
}
@keyframes mma-caret { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* Mathematica 输出行的浅灰底（结果单元格无底色，保留接口） */
.cell-output-graphics .graphics-fallback { color: #666; font-size: 12px; }

/* 建议栏（Wolfram 预测界面）——默认不出现，保留占位样式 */
.predictive-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 22px;
  padding: 0 8px;
  background: #f5f5f5;
  border-top: 1px solid #e8e8e8;
  border-bottom: 1px solid #e8e8e8;
  font: 12px/1 var(--ui-font);
  color: #2b6cb0;
}

/* 滚动条 */
.notebook::-webkit-scrollbar { width: 12px; height: 12px; }
.notebook::-webkit-scrollbar-thumb { background: #c8c8c8; border: 3px solid #f0f0f0; border-radius: 6px; }
.notebook::-webkit-scrollbar-track { background: #f0f0f0; }
.notebook::-webkit-scrollbar-corner { background: #f0f0f0; }

/* 单元格样式（格式 → 样式：Title / Section / Subsection / Text / Input / Output / Code） */
.cell[data-style="Title"] .cell-content,
.cell[data-style="Title"] .cell-output-text { font-size: 24px; line-height: 30px; font-weight: 700; }
.cell[data-style="Section"] .cell-content,
.cell[data-style="Section"] .cell-output-text { font-size: 19px; line-height: 25px; font-weight: 700; }
.cell[data-style="Subsection"] .cell-content,
.cell[data-style="Subsection"] .cell-output-text { font-size: 16px; line-height: 22px; font-weight: 700; }
.cell[data-style="Text"] .cell-content,
.cell[data-style="Text"] .cell-output-text { font-size: 13px; line-height: 20px; font-family: var(--ui-font); }
.cell[data-style="Code"] .cell-content,
.cell[data-style="Code"] .cell-output-text { font-family: var(--mono); font-size: 12px; }
.cell[data-style="Title"] .cell-prompt,
.cell[data-style="Section"] .cell-prompt,
.cell[data-style="Subsection"] .cell-prompt { visibility: hidden; }

/* 对齐辅助线（图形 → 启动对齐辅助线） */
.notebook.align-guides .cell::before {
  content: "";
  position: absolute;
  left: 28px;
  right: 0;
  top: 0;
  bottom: 0;
  border-left: 1px dashed #b7d3ee;
  border-top: 1px dashed #b7d3ee;
  pointer-events: none;
}
