/* SimpleChem 编辑器外壳样式。
   排版（纸张、标题、图表、公式）全部由 document.css 负责，这里只管
   顶栏、左侧插入栏、区块卡片、检查器和弹窗，两者互不重叠。 */

:root {
  --ui-ink: #1f2933;
  --ui-muted: #64707e;
  --ui-line: #d3dbe5;
  /* 只在表格这类必须有网格线的地方使用，其余分隔一律交给阴影和留白。 */
  --ui-line-soft: #e6ecf3;
  --ui-soft: #f3f6fa;
  /* 控件底色：比白色略深一点点，才看得出"这是一个可以点的区域"，
     从而不必再靠一圈边框来说明。 */
  --ui-tint: #f0f4fa;
  --ui-panel: #fafbfe;
  --ui-accent: #143d66;
  --ui-accent-2: #2f7fbf;
  --ui-danger: #b42b2b;
  --ui-ok: #1d7a4d;
  --ui-warn: #a8681a;
  --ui-radius: 12px;
  --ui-radius-sm: 8px;
  --ui-shadow-xs: 0 1px 2px rgba(18, 45, 72, .06);
  --ui-shadow-hover: 0 8px 22px rgba(18, 45, 72, .13), 0 2px 6px rgba(18, 45, 72, .07);
  --ui-shadow: 0 18px 44px rgba(18, 45, 72, .16);
  --ui-ease: .16s ease;
  --ui-sans: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* 滚动条也统一成圆角、半透明，否则默认的方块滚动条最破坏"无边框"的观感。 */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 54, 87, .22) transparent;
}
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
  background-color: rgba(23, 54, 87, .22);
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(23, 54, 87, .38); }
::-webkit-scrollbar-corner { background: transparent; }

/* 键盘走查时给出明确的焦点环；鼠标点击不显示，避免破坏干净的外观。 */
.btn:focus-visible,
.rail button:focus-visible,
.menu button:focus-visible,
.block-actions button:focus-visible,
.rich-toolbar button:focus-visible,
.tool-btn:focus-visible,
.element-btn:focus-visible,
.ring-btn:focus-visible,
.template-card:focus-visible,
.tabs button:focus-visible,
.doc-row button:focus-visible {
  outline: 2px solid var(--ui-accent-2);
  outline-offset: 2px;
}

/* 弹窗、提示这两个容器平时靠 hidden 属性隐藏，但它们自己是 flex，
   必须让 [hidden] 真正生效，否则空容器会盖住整页、吃掉所有点击。 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body.app {
  margin: 0;
  font-family: var(--ui-sans);
  font-size: 14px;
  color: var(--ui-ink);
  background: linear-gradient(180deg, #eef3f9 0%, #e7edf5 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ------------------------------------------------------------------ 顶栏 */

.app-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: #fff;
  box-shadow: 0 6px 18px -14px rgba(18, 45, 72, .55);
  flex: 0 0 auto;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .3px;
  color: var(--ui-accent);
  padding-right: 6px;
}

.brand-mark { font-size: 17px; color: var(--ui-accent-2); }

.doc-title {
  flex: 0 1 320px;
  min-width: 120px;
  font: inherit;
  font-weight: 600;
  color: var(--ui-ink);
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  transition: background var(--ui-ease), box-shadow var(--ui-ease), border-color var(--ui-ease);
}

.doc-title:hover { background: var(--ui-tint); }
.doc-title:focus { outline: none; border-color: var(--ui-accent-2); background: #fff; box-shadow: 0 0 0 3px rgba(47, 127, 191, .14); }

.app-bar-gap { flex: 1 1 auto; }

/* 演示站角标：无边框，只用浅色填充 + 悬停投影，和整体去方框风格一致 */
.demo-badge {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .4px;
  color: var(--ui-warn);
  background: rgba(168, 104, 26, .1);
  padding: 3px 9px;
  border-radius: 999px;
  cursor: help;
  user-select: none;
  white-space: nowrap;
  transition: background var(--ui-ease), box-shadow var(--ui-ease);
}

.demo-badge:hover { background: rgba(168, 104, 26, .17); box-shadow: var(--ui-shadow-hover); }

.btn {
  font: inherit;
  padding: 6px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--ui-tint);
  color: var(--ui-ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--ui-ease), box-shadow var(--ui-ease), color var(--ui-ease);
}

.btn:hover { background: #fff; box-shadow: var(--ui-shadow-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; background: transparent; box-shadow: none; }
.btn-primary { background: var(--ui-accent); color: #fff; box-shadow: var(--ui-shadow-xs); }
.btn-primary:hover { background: #1c5187; box-shadow: var(--ui-shadow-hover); }
.btn-danger { color: var(--ui-danger); background: rgba(180, 43, 43, .08); }
.btn-danger:hover { background: #fdf1f1; }
.btn[aria-pressed="true"] { background: var(--ui-accent); color: #fff; }
.btn-icon { padding: 5px; font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; background: transparent; }
.btn-icon > .icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon-danger { color: var(--ui-muted); }
.btn-icon-danger:hover { color: #fff; background: var(--ui-danger); }

.menu-wrap { position: relative; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 210px;
  background: #fff;
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow);
  padding: 6px;
  z-index: 40;
}

.menu button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  color: var(--ui-ink);
}

.menu button:hover:not(:disabled) { background: var(--ui-soft); }
.menu button:disabled { cursor: not-allowed; color: var(--ui-muted); }
.menu .menu-hint { font-size: 12px; color: var(--ui-muted); }
.menu .menu-sep { height: 1px; background: var(--ui-line); margin: 5px 4px; }

/* ------------------------------------------------------------------ 工作区 */

.workspace {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.rail {
  flex: 0 0 152px;
  padding: 14px 10px;
  background: var(--ui-panel);
  overflow-y: auto;
}

.rail h2 {
  margin: 6px 6px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--ui-muted);
  text-transform: uppercase;
}

.rail button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 7px 10px;
  margin-bottom: 3px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ui-ink);
  cursor: pointer;
  transition: background var(--ui-ease), box-shadow var(--ui-ease);
}

.rail button:hover { background: #fff; box-shadow: var(--ui-shadow-hover); }

.rail .rail-icon {
  display: inline-block;
  width: 18px;
  text-align: center;
  color: var(--ui-accent-2);
  font-weight: 600;
}

.canvas-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 26px 18px 64px;
  min-width: 0;
}

.canvas { max-width: 21cm; margin: 0 auto; }

.preview-frame {
  display: block;
  width: min(21cm, 100%);
  height: calc(100vh - 190px);
  margin: 0 auto;
  border: 0;
  border-radius: var(--ui-radius);
  background: #fff;
  box-shadow: var(--ui-shadow);
}

.canvas-empty {
  max-width: 21cm;
  margin: 28px auto;
  text-align: center;
  color: var(--ui-muted);
  line-height: 1.8;
}

.canvas-empty kbd {
  font: inherit;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--ui-tint);
  box-shadow: var(--ui-shadow-xs);
}

.inspector {
  flex: 0 0 290px;
  padding: 14px;
  background: var(--ui-panel);
  overflow-y: auto;
}

.inspector section {
  padding: 11px 13px;
  border-radius: var(--ui-radius);
  background: #fff;
  box-shadow: var(--ui-shadow-xs);
  transition: box-shadow var(--ui-ease);
}

.inspector section:hover { box-shadow: var(--ui-shadow-hover); }
.inspector section + section { margin-top: 10px; }

.inspector h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ui-accent);
}

.inspector .field { margin-bottom: 9px; }
.inspector .hint { font-size: 12px; color: var(--ui-muted); line-height: 1.55; }
.inspector .kv {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding: 4px 6px;
  margin: 0 -6px;
  border-radius: 7px;
  transition: background var(--ui-ease);
}
.inspector .kv:hover { background: var(--ui-tint); }
.inspector .kv span:last-child { color: var(--ui-muted); }

/* ------------------------------------------------------------------ 区块卡片 */

.block {
  position: relative;
  background: #fff;
  border-radius: var(--ui-radius);
  margin-bottom: 12px;
  box-shadow: var(--ui-shadow-xs);
  transition: box-shadow var(--ui-ease), transform var(--ui-ease);
}

/* 悬停只加阴影、不做位移：卡片一旦 translateY，指针停在最下面 1px 上时会
   反复进出 hover，产生闪烁。 */
.block:hover { box-shadow: var(--ui-shadow-hover); }
.block.is-active { box-shadow: inset 4px 0 0 -1px var(--ui-accent-2), var(--ui-shadow-hover); }
.block.is-dragging { opacity: .45; }

/* 拖动落点用一根浮起的短棒表示，不靠环住整张卡片的高亮描边。 */
.block.drop-before::before,
.block.drop-after::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 3px;
  border-radius: 999px;
  background: var(--ui-accent-2);
  box-shadow: 0 0 0 4px rgba(47, 127, 191, .15);
}
.block.drop-before::before { top: -7px; }
.block.drop-after::after { bottom: -7px; }

.block-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 3px;
  border-radius: var(--ui-radius) var(--ui-radius) 0 0;
}

.block-kind {
  font-size: 12px;
  font-weight: 600;
  color: var(--ui-muted);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ui-tint);
  transition: background var(--ui-ease), color var(--ui-ease);
}

.block.is-active .block-kind { background: rgba(47, 127, 191, .13); color: var(--ui-accent); }

.block-head-gap { flex: 1 1 auto; }

.block-body { padding: 8px 14px 14px; }

/* 操作按钮平时收起来，鼠标移到卡片上或用键盘聚焦时才浮现，
   卡片因此不必再画一圈边框来区分"可操作区域"。 */
.block-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--ui-ease);
}

.block:hover .block-actions,
.block:focus-within .block-actions,
.block.is-active .block-actions { opacity: 1; }

@media (hover: none) {
  .block-actions { opacity: 1; }
}

.block-actions-sep { width: 1px; height: 16px; margin: 0 4px; background: var(--ui-line-soft); }

/* ------------------------------------------------------------------ 表单控件 */

input[type="text"], input[type="number"], select, textarea {
  font: inherit;
  color: var(--ui-ink);
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-tint);
  width: 100%;
  transition: background var(--ui-ease), border-color var(--ui-ease), box-shadow var(--ui-ease);
}

input[type="text"]:hover:not(:focus),
input[type="number"]:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) { background: #fff; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ui-accent-2);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(47, 127, 191, .14);
}

textarea { resize: vertical; min-height: 68px; font-family: Consolas, "Courier New", monospace; }

label.field { display: block; }
label.field > span {
  display: block;
  font-size: 12px;
  color: var(--ui-muted);
  margin-bottom: 3px;
}

.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 120px; }
.row.tight > * { flex: 0 0 auto; }

/* ------------------------------------------------------------------ 富文本 */

.rich {
  min-height: 46px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-tint);
  font-family: var(--ui-sans);
  font-size: 15px;
  line-height: 1.75;
  outline: none;
  transition: background var(--ui-ease), border-color var(--ui-ease), box-shadow var(--ui-ease);
}

.rich:hover:not(:focus) { background: #fff; }

.rich:focus {
  border-color: var(--ui-accent-2);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(47, 127, 191, .14);
}

.rich sub, .rich sup { font-size: .72em; }
.rich:empty::before { content: attr(data-placeholder); color: #9aa5b1; }
.rich h1, .rich h2, .rich h3 { margin: 0; font-size: 1em; }

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 5px;
}

.rich-toolbar button {
  font: inherit;
  min-width: 28px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ui-muted);
  cursor: pointer;
  line-height: 1.2;
  transition: background var(--ui-ease), color var(--ui-ease), box-shadow var(--ui-ease);
}

.rich-toolbar button:hover { background: var(--ui-soft); color: var(--ui-ink); box-shadow: var(--ui-shadow-xs); }
.rich-toolbar .sep { width: 1px; background: var(--ui-line-soft); margin: 2px 3px; }

/* ------------------------------------------------------------------ 反应式编辑 */

.reaction-grid {
  display: grid;
  grid-template-columns: 1fr 128px 1fr;
  gap: 8px;
  align-items: start;
}

.preview-box {
  border: 0;
  border-radius: var(--ui-radius-sm);
  padding: 12px;
  background: var(--ui-tint);
  overflow: auto;
}

.preview-box .simplechem { min-height: 0; }
.preview-box .ce-doc-head { display: none; }

/* ------------------------------------------------------------------ 表格编辑 */

.grid-editor { overflow-x: auto; }
.grid-editor table { border-collapse: collapse; width: 100%; }
.grid-editor th, .grid-editor td { border: 1px solid var(--ui-line-soft); padding: 0; }
.grid-editor input {
  border: 0;
  border-radius: 0;
  padding: 5px 7px;
  min-width: 90px;
  background: transparent;
}
/* 表格里的输入框已经有网格线，再加底色和投影就太吵了。
   选择器写成和上面的 hover 规则同样的特异性，靠顺序覆盖它。 */
.grid-editor input[type="text"]:hover:not(:focus) { background: #f4f9ff; box-shadow: none; }
.grid-editor input:focus { box-shadow: none; background: #f4f9ff; }
.grid-editor th input { font-weight: 600; background: var(--ui-tint); }
.grid-editor .grid-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ 列表编辑 */

.item-row { display: flex; gap: 6px; align-items: center; margin-bottom: 5px; }
.item-row .item-no { width: 22px; text-align: right; color: var(--ui-muted); font-size: 12px; }

/* ------------------------------------------------------------------ 结构卡片 */

.structure-preview {
  text-align: center;
  padding: 12px;
  border: 0;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-tint);
  min-height: 80px;
}

.structure-preview img { max-width: 100%; }

.inline-error { color: var(--ui-danger); font-size: 13px; }
.inline-ok { color: var(--ui-ok); font-size: 13px; }

/* ------------------------------------------------------------------ 状态栏 */

.status-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--ui-muted);
  background: #fff;
  box-shadow: 0 -8px 18px -14px rgba(18, 45, 72, .5);
}

.status-gap { flex: 1 1 auto; }
.status-bar .dot { color: var(--ui-ok); }
.status-bar .dot.dirty { color: var(--ui-warn); }
.status-bar .dot.error { color: var(--ui-danger); }

/* ------------------------------------------------------------------ 提示 */

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 44px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
}

.toast {
  background: #fff;
  border-radius: 10px;
  border-left: 4px solid var(--ui-accent-2);
  box-shadow: var(--ui-shadow);
  padding: 10px 14px;
  max-width: 360px;
  animation: toast-in .18s ease-out;
}

.toast.error { border-left-color: var(--ui-danger); }
.toast.ok { border-left-color: var(--ui-ok); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ 弹窗 */

.modal-host {
  position: fixed;
  inset: 0;
  background: rgba(16, 32, 51, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 60;
}

.modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(16, 32, 51, .28);
  width: min(820px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.modal.narrow { width: min(520px, 100%); }
.modal.wide { width: min(1080px, 100%); }

.modal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--ui-line-soft);
}

.modal-head h2 { margin: 0; font-size: 15px; color: var(--ui-accent); flex: 1 1 auto; }

.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--ui-line-soft);
  border-radius: 0 0 14px 14px;
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ui-line-soft); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button {
  font: inherit;
  padding: 7px 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--ui-muted);
}
.tabs button:hover { color: var(--ui-ink); }
.tabs button[aria-selected="true"] { color: var(--ui-accent); border-bottom-color: var(--ui-accent); font-weight: 600; }

.template-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.template-card {
  text-align: left;
  font: inherit;
  padding: 13px;
  border: 0;
  border-radius: var(--ui-radius);
  background: var(--ui-tint);
  cursor: pointer;
  transition: background var(--ui-ease), box-shadow var(--ui-ease), transform var(--ui-ease);
}
.template-card:hover { background: #fff; box-shadow: var(--ui-shadow-hover); }
.template-card strong { display: block; margin-bottom: 4px; color: var(--ui-accent); }
.template-card span { font-size: 12px; color: var(--ui-muted); }

.doc-list .hint { font-size: 12px; color: var(--ui-muted); }

.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--ui-radius);
  background: var(--ui-tint);
  transition: background var(--ui-ease), box-shadow var(--ui-ease);
}
.doc-row:hover { background: #fff; box-shadow: var(--ui-shadow-hover); }
.doc-row .doc-main { flex: 1 1 auto; min-width: 0; }
.doc-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .doc-sub { font-size: 12px; color: var(--ui-muted); margin-top: 2px; }

/* ------------------------------------------------------------------ 画板 */

/* 三栏：左边是工具 / 设置 / 操作，中间是画布，右边是元素和环模板。
 * 画板尺寸跟着画布像素走（720×480），导出时按同一坐标系渲染。 */
.modal.board { width: min(1400px, 100%); }

.board-wrap { display: flex; gap: 12px; align-items: flex-start; }

.board-side {
  flex: 0 0 186px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 76vh;
  overflow-y: auto;
  padding: 10px;
  border-radius: var(--ui-radius);
  background: var(--ui-panel);
}
.board-side.right { flex: 0 0 226px; }

.board-side h3 {
  margin: 10px 0 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ui-muted);
}
.board-side h3:first-child { margin-top: 0; }

/* 分组之间只画一根极淡的分隔线，比给每组都套一个方框轻得多。 */
.board-side h3:not(:first-child) {
  padding-top: 10px;
  border-top: 1px solid var(--ui-line-soft);
}

/* 画布是固定 720×480 的画板坐标系，中间栏不参与收缩，否则右侧元素列表会压住画布右缘。 */
.board-stage { flex: 0 0 auto; min-width: 0; }
/* 边框放在外层：这样 canvas 的 bounding rect 就等于 720×480 的画板坐标系，
 * board.js 用 rect 换算指针坐标时不会有边框带来的偏差。 */
.board-frame {
  display: inline-block;
  line-height: 0;
  border-radius: var(--ui-radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--ui-shadow-xs);
}

.board-canvas {
  /* content-box 让 CSS 宽度与位图宽度的换算保持精确（720 CSS px ↔ 720·dpr 像素）。 */
  box-sizing: content-box;
  display: block;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}

.board-hint { font-size: 12px; color: var(--ui-muted); line-height: 1.5; margin: 8px 0 0; }
.board-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--ui-muted); margin-top: 4px; }

.board-tools { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-tint);
  color: var(--ui-ink);
  cursor: pointer;
  text-align: left;
  transition: background var(--ui-ease), box-shadow var(--ui-ease), color var(--ui-ease);
}
.tool-btn:hover { background: #fff; box-shadow: var(--ui-shadow-hover); }
.tool-btn.active { background: rgba(47, 127, 191, .13); color: var(--ui-accent); box-shadow: inset 0 0 0 1px rgba(47, 127, 191, .35); }
.tool-icon { flex: 0 0 auto; width: 16px; text-align: center; font-size: 13px; color: var(--ui-accent); }

.board-settings { display: flex; flex-direction: column; gap: 6px; }
.board-field { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ui-muted); }
.board-field > span:first-child { flex: 0 0 62px; }
.board-field input[type="text"], .board-field input[type="number"], .board-field select {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--ui-tint);
  color: var(--ui-ink);
}
.board-field.checkbox { gap: 6px; }
.board-field.checkbox > span { flex: 1 1 auto; }

.board-current, .board-selected {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ui-muted);
}
.board-selected { color: var(--ui-accent); }
.board-selected > span:first-child { flex: 1 1 auto; }

.board-actions { display: flex; flex-direction: column; gap: 4px; }

.btn-tiny { font-size: 12px; padding: 4px 8px; }

.palette-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.palette-row { display: flex; gap: 3px; align-items: center; }
.palette-gap { flex: 0 0 6px; }
.palette-tag { flex: 1 1 auto; font-size: 9px; color: var(--ui-muted); text-align: center; white-space: nowrap; }
.palette-all { display: grid; gap: 2px; margin-top: 4px; }

.element-btn {
  font: inherit;
  font-size: 12px;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: var(--ui-tint);
  color: var(--ui-ink);
  cursor: pointer;
  transition: background var(--ui-ease), box-shadow var(--ui-ease), color var(--ui-ease);
}
.element-btn:hover { background: #fff; box-shadow: var(--ui-shadow-hover); }
.element-btn.tiny { aspect-ratio: auto; font-size: 11px; padding: 2px 0; }
.element-btn.active { background: var(--ui-accent); color: #fff; box-shadow: var(--ui-shadow-xs); }

.ring-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.ring-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  border: 0;
  border-radius: 7px;
  background: var(--ui-tint);
  cursor: pointer;
  text-align: left;
  transition: background var(--ui-ease), box-shadow var(--ui-ease);
}
.ring-btn:hover { background: #fff; box-shadow: var(--ui-shadow-hover); }
.ring-btn.active { background: #fff; box-shadow: inset 0 0 0 1px rgba(47, 127, 191, .4), var(--ui-shadow-hover); }
.ring-preview { display: inline-flex; flex: 0 0 30px; width: 30px; height: 30px; }

.board-result { font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.board-kv { display: flex; gap: 6px; }
.board-kv .k { flex: 0 0 58px; color: var(--ui-muted); }
.board-kv .v { flex: 1 1 auto; word-break: break-all; }

.board-note { flex: 1 1 auto; font-size: 12px; color: var(--ui-muted); }
.grow { flex: 1 1 auto; }

.result-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.result-table th, .result-table td { border: 1px solid var(--ui-line-soft); padding: 5px 8px; text-align: left; }
.result-table th { background: var(--ui-tint); }

.calc-summary { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; font-size: 13px; margin-bottom: 10px; }
.calc-summary dt { color: var(--ui-muted); }
.calc-summary dd { margin: 0; }

/* ------------------------------------------------------------------ 自适应 */

/* 上面这些过渡只是装饰，系统开了"减少动态效果"时应该关掉。 */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

@media (max-width: 1100px) {
  .inspector { display: none; }
}

/* 画板三栏需要 186 + 12 + 722 + 12 + 226 = 1158 px 的内容宽度，
 * 视口不够时把两侧面板收成上下排布，避免画布被压住。 */
@media (max-width: 1250px) {
  .board-wrap { flex-direction: column; }
  .board-side, .board-side.right { flex: 0 0 auto; width: 100%; max-height: none; overflow: visible; }
  .board-tools { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 820px) {
  .rail { flex-basis: 118px; }
  .workspace { flex-direction: column; }
  .rail { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--ui-line-soft); overflow: visible; }
  .rail h2 { flex: 1 0 100%; }
  .rail button { width: auto; margin: 0 4px 4px 0; }
  .reaction-grid { grid-template-columns: 1fr; }
}
