/* Mathematica 12 网页复刻 · 本轮功能样式（web/css/features.css）
 *
 * 覆盖本轮「部分 -> 一致」的界面元素：
 *   多文档标签页（NB-06）/ 偏好设置表单（NB-09）/ 深色主题（NB-10）/
 *   单元属性标记（CL-05）/ 二维排版输入与回显（CL-07）/ 查找替换（CL-09）/
 *   消息行（IO-06）/ 二维表格输出（IO-07）/ 语法高亮与自动补全（IO-09）/
 *   三维画布与交互（PLT-02/05/07）/ 颜色选择器（PAL-07）/ 快捷键速查（HLP-05）。
 *
 * 注意：默认单文档 + 浅色主题时不得影响既有像素基线（ui-check 的 blank 截图）。
 */

/* ---------- 多文档标签页（NB-06） ---------- */
.doc-tabs {
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
  height: 22px;
  background: #ececec;
  border-bottom: 1px solid #d0d0d0;
  overflow-x: auto;
  overflow-y: hidden;
  user-select: none;
}
.doc-tabs[hidden] { display: none; }
.doc-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 120px;
  max-width: 240px;
  padding: 0 6px 0 10px;
  border-right: 1px solid #d0d0d0;
  background: #f5f5f5;
  color: #333;
  font: 12px/22px var(--ui-font);
  white-space: nowrap;
  cursor: pointer;
}
.doc-tab.is-active { background: #ffffff; color: #000; box-shadow: inset 0 -2px 0 #5e81b5; }
.doc-tab-label { overflow: hidden; text-overflow: ellipsis; }
.doc-tab-close {
  border: 0;
  background: transparent;
  color: #777;
  font: 12px/1 var(--ui-font);
  cursor: pointer;
  padding: 2px 3px;
  border-radius: 2px;
}
.doc-tab-close:hover { background: #e81123; color: #fff; }
.doc-tab-add {
  flex: 0 0 26px;
  width: 26px;
  border: 0;
  border-right: 1px solid #d0d0d0;
  background: #f0f0f0;
  color: #555;
  font: 14px/22px var(--ui-font);
  cursor: pointer;
}
.doc-tab-add:hover { background: #e0edf8; }

/* ---------- 语法高亮（IO-09） ---------- */
.cell-highlight {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-family: var(--cell-font);
  font-size: 14px;
  line-height: 19px;
  color: transparent;
}
.cell-highlight .hl-number { color: #000000; }
.cell-highlight .hl-symbol { color: #000000; }
.cell-highlight .hl-function { color: #1a4a8a; }
.cell-highlight .hl-constant { color: #6a1a8a; }
.cell-highlight .hl-string { color: #a52a2a; }
.cell-highlight .hl-comment { color: #5a5a5a; font-style: italic; }
.cell-highlight .hl-bracket { color: #000000; }
.cell-highlight .hl-operator { color: #333333; }
.cell-content.has-highlight {
  position: relative;
  z-index: 1;
  color: transparent;
  caret-color: #000000;
}
.cell-content.has-highlight::selection { background: #cce6ff; color: #000000; }

/* ---------- 自动补全 / 函数名提示（IO-09） ---------- */
.autocomplete-popup {
  position: absolute;
  z-index: 60;
  min-width: 220px;
  max-width: 340px;
  background: #ffffff;
  border: 1px solid #9aa7b8;
  box-shadow: 2px 3px 10px rgba(0, 0, 0, 0.18);
  font: 12px/1.4 var(--ui-font);
}
.autocomplete-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 8px;
  cursor: pointer;
}
.autocomplete-item.is-active { background: #cfe4f7; }
.autocomplete-item .ac-name { font-family: var(--mono); color: #1a4a8a; }
.autocomplete-item .ac-desc { color: #777; }
.function-hint {
  margin: 1px 0 0 4px;
  padding: 1px 6px;
  display: inline-block;
  background: #f3f7fb;
  border: 1px solid #d8e4f0;
  color: #456;
  font: 11px/1.4 var(--ui-font);
  border-radius: 2px;
}
.function-hint[hidden] { display: none; }

/* ---------- 消息行（IO-06） ---------- */
.cell-messages { margin: 2px 0 4px 0; }
.cell-message {
  color: #8a2c1a;
  font: 12px/1.5 var(--ui-font);
  background: #fdf3f0;
  border-left: 2px solid #c97b63;
  padding: 1px 6px;
  margin: 2px 0;
}
.cell-message .message-name { font-weight: 600; color: #a03a22; margin-right: 3px; }

/* ---------- 二维表格输出（IO-07） ---------- */
.cell-output-form { margin: 2px 0; }
.output-table { border-collapse: collapse; font-family: var(--cell-font); font-size: 14px; }
.output-table td {
  padding: 1px 10px;
  text-align: center;
  border: 1px solid transparent;
}
.cell-output-form .output-table { border-left: 2px solid #555; border-right: 2px solid #555; border-radius: 2px; }

/* ---------- 二维排版：输出回显（CL-07） ---------- */
.typeset-output {
  font-family: var(--cell-font);
  font-size: 15px;
  line-height: 1.6;
  color: #000000;
  padding: 1px 0;
}
.typeset-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  margin: 0 2px;
}
.typeset-frac .typeset-num { display: block; border-bottom: 1px solid #333; padding: 0 4px; }
.typeset-frac .typeset-den { display: block; padding: 0 4px; }
.typeset-power { display: inline-block; vertical-align: baseline; }
.typeset-power .typeset-sup, .typeset-power .typeset-sub { font-size: 82%; line-height: 0; }
.typeset-root { display: inline-block; }
.typeset-root .typeset-root-symbol { font-size: 1.1em; }
.typeset-root .typeset-radicand { border-top: 1px solid #333; padding: 0 2px; }

/* ---------- 二维排版：输入模板（CL-07） ---------- */
.typeset-input {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin: 0 2px;
  padding: 1px 2px;
  border: 1px dashed #b9cfe2;
  border-radius: 2px;
  background: #fbfdff;
  cursor: text;
}
.typeset-input .typeset-field {
  display: inline-block;
  min-width: 1.1em;
  min-height: 1.15em;
  padding: 0 3px;
  outline: none;
  background: #ffffff;
  border-radius: 2px;
  text-align: center;
  font-family: var(--cell-font);
  font-size: 14px;
  line-height: 1.15;
}
.typeset-input .typeset-field:empty::before {
  content: "?";
  color: #b0c4d8;
}
.typeset-input .typeset-field:focus { background: #eef6ff; box-shadow: 0 0 0 1px #9cc3e6; }
.typeset-input.typeset-frac { flex-direction: column; align-items: stretch; }
.typeset-input.typeset-frac .typeset-num { display: block; border-bottom: 1px solid #333; border-radius: 0; text-align: center; }
.typeset-input.typeset-frac .typeset-den { display: block; border-radius: 0; text-align: center; }
.typeset-input.typeset-power { display: inline-flex; align-items: flex-start; }
.typeset-input.typeset-power .typeset-sup { position: relative; top: -0.35em; }
.typeset-input.typeset-power .typeset-sub { position: relative; top: 0.35em; }
.typeset-input.typeset-root .typeset-radicand { border-top: 1px solid #333; border-radius: 0; }
.typeset-input.typeset-integral-input { display: inline-flex; align-items: center; gap: 1px; }
.typeset-integral-symbol { font: 20px/1 var(--cell-font); }
.typeset-integral-limits { display: inline-flex; flex-direction: column; align-items: flex-start; margin-right: 2px; }
.typeset-integral-limits .typeset-field { min-width: 1.4em; min-height: 0.9em; font-size: 11px; padding: 0 2px; }
.typeset-integral-limits .typeset-upper { border-bottom: 1px solid #ccc; }
.typeset-integral-input .typeset-integrand { min-width: 2.2em; }
.typeset-input.typeset-matrix-input {
  display: inline-grid;
  gap: 1px;
  padding: 3px 4px;
}
.typeset-matrix-row { display: flex; gap: 2px; }

/* ---------- 偏好设置（NB-09） ---------- */
.preferences-form { display: grid; gap: 6px; margin-top: 6px; }
.pref-row {
  display: grid;
  grid-template-columns: 170px 190px;
  align-items: center;
  gap: 4px 12px;
  padding: 3px 0;
  border-bottom: 1px dotted #e4e4e4;
}
.pref-label { color: #333; }
.pref-control { font: 12px/1.4 var(--ui-font); padding: 2px 4px; }
.pref-help { grid-column: 1 / span 2; color: #888; font-size: 11px; }

/* ---------- 颜色选择器（PAL-07） ---------- */
.colorpicker-field {
  display: block;
  border: 1px solid #9aa7b8;
  cursor: crosshair;
  margin: 6px 0;
}
.colorpicker-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.colorpicker-swatch {
  display: inline-block;
  width: 38px;
  height: 24px;
  border: 1px solid #666;
  background: #5e81b5;
}
.colorpicker-label { display: inline-flex; align-items: center; gap: 3px; color: #444; }
.colorpicker-input {
  width: 52px;
  padding: 2px 4px;
  font: 12px/1.3 var(--mono);
  border: 1px solid #b8b8b8;
}
.colorpicker-hex { width: 82px; }
.colorpicker-actions { margin-top: 8px; }
.colorpicker-hint { margin-top: 6px; color: #666; min-height: 16px; }

/* ---------- 完整命令名（IO-09） ---------- */
.command-name-list { max-height: 260px; overflow: auto; margin-top: 6px; border: 1px solid #ddd; }
.command-name-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 3px 8px;
  border: 0;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
  text-align: left;
  cursor: pointer;
  font: 12px/1.4 var(--ui-font);
}
.command-name-item:hover { background: #e8f1fa; }
.command-name-item .ac-name { font-family: var(--mono); color: #1a4a8a; }
.command-name-item .ac-desc { color: #777; }

/* ---------- 快捷键速查（HLP-05） ---------- */
.shortcut-table { border-collapse: collapse; width: 100%; font: 12px/1.5 var(--ui-font); }
.shortcut-table th, .shortcut-table td { border-bottom: 1px solid #eee; padding: 3px 8px; text-align: left; }
.shortcut-table th { background: #f5f5f5; }
.shortcut-key { font-family: var(--mono); color: #1a4a8a; white-space: nowrap; }

/* ---------- 窗口重排（NB-06） ---------- */
.window-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.window-card { border: 1px solid #ccd6e0; background: #fbfdff; padding: 8px; border-radius: 3px; }
.window-card.is-active { border-color: #5e81b5; box-shadow: inset 0 0 0 1px #5e81b5; }
.window-card-title { font-weight: 600; margin-bottom: 8px; }
.window-card-actions { display: flex; gap: 6px; }

/* ---------- 单元属性标记（CL-05） ---------- */
.cell.is-initialization .cell-prompt { color: #8a6d3b; }
.cell.is-initialization { background: #fdfaf3; }
.cell.is-not-evaluatable .cell-prompt { color: #999; }
.cell.is-not-evaluatable .cell-content { color: #777; }

/* ---------- 深色主题（NB-10） ---------- */
html[data-theme="dark"] {
  --titlebar-bg: #2b2f36;
  --titlebar-text: #e8e8e8;
  --menubar-bg: #31363e;
  --menubar-border: #22262c;
  --toolbar-bg: #2a2e35;
  --toolbar-border: #22262c;
  --notebook-bg: #1e2227;
  --bottombar-bg: #2a2e35;
  --text: #e6e6e6;
  --muted: #a8a8a8;
  --prompt: #7fb0e0;
  --bracket: #7a7a7a;
  --cell-line: #4a4a4a;
  --hover: #3a4656;
  --selection: #2f4a6a;
}
html[data-theme="dark"] body { background: #1e2227; color: #e6e6e6; }
html[data-theme="dark"] .cell-content { color: #e6e6e6; caret-color: #e6e6e6; }
html[data-theme="dark"] .cell-highlight .hl-number,
html[data-theme="dark"] .cell-highlight .hl-symbol,
html[data-theme="dark"] .cell-highlight .hl-bracket { color: #e6e6e6; }
html[data-theme="dark"] .cell-highlight .hl-function { color: #8fb8ee; }
html[data-theme="dark"] .cell-highlight .hl-constant { color: #c8a2e8; }
html[data-theme="dark"] .cell-highlight .hl-string { color: #e8a0a0; }
html[data-theme="dark"] .cell-highlight .hl-comment { color: #9a9a9a; }
html[data-theme="dark"] .cell-highlight .hl-operator { color: #c0c0c0; }
html[data-theme="dark"] .cell-content.has-highlight { caret-color: #e6e6e6; }
html[data-theme="dark"] .dialog { background: #262a30; color: #e6e6e6; border-color: #4a4a4a; }
html[data-theme="dark"] .dialog-titlebar { background: #33383f; border-color: #4a4a4a; }
html[data-theme="dark"] .dialog-btn { background: #3a3f47; color: #e6e6e6; border-color: #555; }
html[data-theme="dark"] .dialog-body code { color: #cfe0f0; }
html[data-theme="dark"] .menu-panel { background: #2e333a; border-color: #4a4a4a; color: #e6e6e6; }
html[data-theme="dark"] .menu-item:hover { background: #3a4656; }
html[data-theme="dark"] .menu-separator { border-color: #444; }
html[data-theme="dark"] .output-table td { color: #e6e6e6; }
html[data-theme="dark"] .typeset-output { color: #e6e6e6; }
html[data-theme="dark"] .typeset-frac .typeset-num,
html[data-theme="dark"] .typeset-root .typeset-radicand,
html[data-theme="dark"] .typeset-input.typeset-frac .typeset-num,
html[data-theme="dark"] .typeset-input.typeset-root .typeset-radicand { border-color: #aaa; }
html[data-theme="dark"] .typeset-input { background: #2a2f36; border-color: #4a5a6a; }
html[data-theme="dark"] .typeset-input .typeset-field { background: #23272d; color: #e6e6e6; }
html[data-theme="dark"] .autocomplete-popup { background: #2e333a; border-color: #4a5a6a; }
html[data-theme="dark"] .autocomplete-item.is-active { background: #3a4656; }
html[data-theme="dark"] .autocomplete-item .ac-desc { color: #a0a0a0; }
html[data-theme="dark"] .function-hint { background: #2a3038; border-color: #445; color: #b8c8d8; }
html[data-theme="dark"] .cell-message { background: #3a2a26; border-color: #c97b63; color: #e8b8a8; }
html[data-theme="dark"] .doc-tabs { background: #262a30; border-color: #444; }
html[data-theme="dark"] .doc-tab { background: #2e333a; color: #ddd; border-color: #444; }
html[data-theme="dark"] .doc-tab.is-active { background: #1e2227; color: #fff; }
html[data-theme="dark"] .command-name-list { border-color: #444; }
html[data-theme="dark"] .command-name-item { background: #262a30; color: #ddd; border-color: #333; }
html[data-theme="dark"] .command-name-item:hover { background: #3a4656; }
html[data-theme="dark"] .shortcut-table th { background: #33383f; }
html[data-theme="dark"] .shortcut-table th,
html[data-theme="dark"] .shortcut-table td { border-color: #3a3f47; }
html[data-theme="dark"] .window-card { background: #262a30; border-color: #445; }
html[data-theme="dark"] .colorpicker-field { border-color: #556; }
html[data-theme="dark"] .colorpicker-label { color: #ccc; }
html[data-theme="dark"] .colorpicker-input { background: #23272d; color: #eee; border-color: #555; }

/* ---------- 三维画布（PLT-02/05/07） ---------- */
.cell-output-graphics canvas[data-plot3d="true"] {
  cursor: grab;
  border: 1px solid #e2e2e2;
  background: #ffffff;
}
.cell-output-graphics canvas[data-plot3d="true"]:active { cursor: grabbing; }
/* ---------- 调色板停靠面板（PAL-08：按真机面板截图实测形态） ----------
 * 基线：docs/reference/palette-panels.json
 *   - 面板贴主窗口右缘停靠，宽度按调色板不同（数学助手 283px / 特殊字符 310px / 色彩方案 231px）；
 *   - 标题栏 30px、面板底色 #f0f0f0、分区线 #b8b8b8、内容盒 #f9f9f9 + #e5e5e5 边框；
 *   - 分区标题可折叠（蓝色三角），分区内页签切换。
 * 颜色变量由 palette-dock.js 从真机基线写入，样式表只引用变量。
 */
.palette-dock {
  position: fixed;
  right: 0;
  top: 88px;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 1px;
  z-index: 30;
  overflow: auto;
  pointer-events: none;
}
.palette-dock > * { pointer-events: auto; }
.palette-window {
  display: flex;
  flex-direction: column;
  background: var(--palette-body-bg, #f0f0f0);
  border: 1px solid #c8c8c8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  font: var(--palette-font-size, 11px)/1.35 var(--palette-font, "Segoe UI", "Microsoft YaHei", sans-serif);
  color: #1a1a1a;
  max-height: 100%;
  overflow: hidden;
}
.palette-titlebar {
  display: flex;
  align-items: center;
  gap: 5px;
  height: var(--palette-titlebar-height, 30px);
  min-height: var(--palette-titlebar-height, 30px);
  padding: 0 0 0 6px;
  background: var(--palette-titlebar-bg, #f3f3f3);
  border-bottom: 1px solid #c8c8c8;
}
.palette-icon { color: #c0392b; font-size: 10px; line-height: 1; }
.palette-title { font-size: 12px; }
.palette-close {
  margin-left: auto;
  width: var(--palette-titlebar-height, 30px);
  height: calc(var(--palette-titlebar-height, 30px) - 1px);
  border: 0;
  border-left: 1px solid #c8c8c8;
  background: var(--palette-close-bg, #dbdbdb);
  color: #333;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
}
.palette-close:hover { background: #c75050; color: #fff; }
.palette-body { background: var(--palette-body-bg, #f0f0f0); overflow: auto; padding-bottom: 2px; }
.palette-section-title {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  margin: 0;
  padding: 3px 6px 2px 4px;
  border: 0;
  border-top: 2px solid var(--palette-rule, #b8b8b8);
  background: transparent;
  color: #1a1a1a;
  font: 600 11px/1.4 var(--palette-font, "Segoe UI", "Microsoft YaHei", sans-serif);
  text-align: left;
  cursor: pointer;
}
.palette-section:first-child > .palette-section-title { border-top: 0; }
.palette-section-triangle { color: var(--palette-triangle, #003399); font-size: 9px; width: 9px; }
.palette-section-label { flex: 1 1 auto; }
.palette-help {
  width: 15px;
  height: 15px;
  border: 1px solid #7a7a7a;
  border-radius: 50%;
  background: #cfd6dd;
  color: #333;
  font: 700 9px/13px var(--palette-font, sans-serif);
  text-align: center;
}
.palette-section-body { padding: 2px 5px 4px 5px; }
.palette-tabs { display: flex; padding-left: 12px; }
.palette-tab {
  border: 1px solid #c8c8c8;
  border-bottom: 0;
  background: var(--palette-tab-inactive-bg, #f0f0f0);
  color: #333;
  font: 11px/1.3 var(--palette-font, "Segoe UI", sans-serif);
  padding: 4px 10px 3px 10px;
  cursor: pointer;
}
.palette-tab[data-active="true"] {
  background: var(--palette-tab-active-bg, #f9f9f9);
  border-bottom: 1px solid var(--palette-tab-active-bg, #f9f9f9);
  margin-bottom: -1px;
  font-weight: 600;
}
.palette-content {
  background: var(--palette-content-bg, #f9f9f9);
  border: 1px solid var(--palette-content-border, #e5e5e5);
  padding: 5px 4px 5px 4px;
}
.palette-grid {
  display: grid;
  grid-template-columns: repeat(var(--palette-columns, 8), minmax(0, 1fr));
  gap: 1px;
  background: var(--palette-btn-border, #dcdcdc);
  border: 1px solid var(--palette-btn-border, #dcdcdc);
  margin: 0 0 5px 0;
}
.palette-content > .palette-grid:last-child { margin-bottom: 0; }
.palette-btn {
  height: 26px;
  min-width: 0;
  border: 0;
  background: var(--palette-btn-bg, #f9f9f9);
  color: #1a1a1a;
  font: 10px/1.2 var(--palette-font, "Segoe UI", sans-serif);
  padding: 0 1px;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  cursor: pointer;
}
.palette-btn:hover { background: #e8eef7; }
.palette-btn-empty { cursor: default; background: #ffffff; }
.palette-variants {
  display: grid;
  grid-template-columns: repeat(var(--variant-columns, 6), minmax(0, 1fr));
  gap: 1px;
  background: var(--palette-btn-border, #dcdcdc);
  border: 1px solid var(--palette-btn-border, #dcdcdc);
  margin: 0 0 5px 0;
}
.palette-variant {
  height: 26px;
  border: 0;
  background: var(--palette-btn-bg, #f9f9f9);
  color: #1a1a1a;
  font: 12px/1.2 var(--palette-font, "Segoe UI", sans-serif);
  cursor: pointer;
}
.palette-variant:hover { background: #e8eef7; }
.palette-list { background: var(--palette-content-bg, #f9f9f9); }
.palette-list-item {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 2px 3px 3px 3px;
  text-align: left;
  cursor: pointer;
}
.palette-list-item[data-selected="true"] {
  background: #ededf2;
  border-color: #a8b3c4;
}
.palette-list-label { display: block; font: 600 11px/1.3 var(--palette-font, "Segoe UI", sans-serif); color: #1a1a1a; }
.palette-list-strip { display: block; height: 20px; width: 100%; border: 1px solid #8a8a8a; }
.palette-gradient { margin-top: 5px; }
.palette-gradient-box { border: 1px solid #c8c8c8; background: var(--palette-content-bg, #f9f9f9); padding: 4px; }
.palette-gradient-label { font: 600 11px/1.3 var(--palette-font, "Segoe UI", sans-serif); }
.palette-gradient-bar { height: 20px; margin: 3px 0 1px 0; border: 1px solid #8a8a8a; }
.palette-gradient-ticks { display: flex; justify-content: space-between; font-size: 10px; color: #333; }
.palette-action {
  display: block;
  width: 100%;
  height: 26px;
  margin-top: 6px;
  border: 1px solid #c8c8c8;
  border-radius: 2px;
  background: #fdfdfd;
  color: #1a1a1a;
  font: 11px/1.2 var(--palette-font, "Segoe UI", sans-serif);
  cursor: pointer;
}
.palette-action:hover { background: #e8eef7; }
html[data-theme="dark"] .palette-window { border-color: #3a3f47; color: #e6e6e6; }
html[data-theme="dark"] .palette-body,
html[data-theme="dark"] .palette-window { background: #262a30; }
html[data-theme="dark"] .palette-titlebar { background: #333840; border-color: #3a3f47; }
html[data-theme="dark"] .palette-section-title { color: #e6e6e6; border-top-color: #4a5058; }
html[data-theme="dark"] .palette-content,
html[data-theme="dark"] .palette-gradient-box { background: #2b3037; border-color: #3a3f47; }
html[data-theme="dark"] .palette-btn,
html[data-theme="dark"] .palette-variant { background: #2b3037; color: #e6e6e6; }
html[data-theme="dark"] .palette-tab { background: #2b3037; color: #ddd; border-color: #3a3f47; }
html[data-theme="dark"] .palette-tab[data-active="true"] { background: #343a42; }
html[data-theme="dark"] .palette-list-item[data-selected="true"] { background: #38414e; }
html[data-theme="dark"] .palette-action { background: #2b3037; color: #e6e6e6; border-color: #3a3f47; }
