/* Manual magazine editor */

.editor-modal[open] {
  padding: 20px;
}

.editor-card {
  width: min(1240px, calc(100vw - 40px));
  height: min(880px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
}

.editor-head {
  align-items: center;
  flex: none;
  padding: 20px 27px 17px;
}

.editor-head h2 {
  font-size: clamp(24px, 2.4vw, 33px);
}

.editor-head-note {
  margin: 5px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.editor-body {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
}

.editor-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 16px 15px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(250, 247, 240, 0.8), rgba(236, 230, 220, 0.35));
}

.editor-title-field > span {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
}

.editor-title-field input {
  padding: 5px 0 8px;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.3;
}

.editor-pages-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 17px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.editor-pages-head .modal-kicker {
  margin-bottom: 3px;
  font-size: 7px;
}

.editor-pages-head strong {
  display: block;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
}

.editor-page-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.editor-page-actions button,
.editor-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 29px;
  height: 29px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.editor-page-actions button {
  gap: 3px;
  padding: 0 6px;
  border-color: var(--line);
  background: rgba(250, 247, 240, 0.55);
}

.editor-page-actions button:hover,
.editor-toolbar button:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(24, 35, 30, 0.045);
}

.editor-page-actions button:disabled,
.editor-toolbar button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.editor-page-actions [data-icon] {
  font-size: 12px;
}

.editor-page-actions .icon-only {
  width: 29px;
  padding: 0;
}

.editor-page-list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 10px -7px 0;
  padding: 0 7px 2px;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.editor-page-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 6px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.editor-page-item:hover {
  background: rgba(250, 247, 240, 0.65);
}

.editor-page-item.is-active {
  border-color: rgba(184, 75, 49, 0.32);
  background: rgba(250, 247, 240, 0.94);
}

.editor-page-thumb {
  position: relative;
  display: block;
  flex: none;
  width: 46px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 4px 8px -6px rgba(24, 35, 30, 0.45);
}

.editor-page-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.editor-page-blank {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 6px;
  letter-spacing: 0.08em;
}

.editor-page-dot {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 5px;
  height: 5px;
  border: 1px solid #fff;
  border-radius: 50%;
  background: var(--accent);
}

.editor-page-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.editor-page-copy strong {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.editor-page-copy small {
  overflow: hidden;
  color: var(--faint);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-page-item.is-active .editor-page-copy strong {
  color: var(--accent);
}

.editor-side-note {
  flex: none;
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 8px;
  line-height: 1.7;
}

.editor-workspace {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #e9e3d8;
}

.editor-toolbar {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 8px 13px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 247, 240, 0.8);
}

.editor-tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 6px;
  border-right: 1px solid var(--line);
}

.editor-tool-group:last-child {
  border-right: 0;
}

.editor-tool-group-end {
  margin-left: auto;
}

.editor-toolbar button {
  gap: 4px;
}

.editor-toolbar button.wide {
  min-width: 34px;
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.02em;
}

.editor-toolbar button.is-active {
  border-color: rgba(184, 75, 49, 0.32);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.tool-underline {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.editor-toolbar [data-icon] {
  font-size: 11px;
}

.editor-viewport {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 20px;
  overflow: auto;
  /* 适应窗口时保持原生触摸行为，编辑文字、放置光标都正常；
     放大后交给 JS 接管：双指捏合缩放、单指拖动平移。 */
  touch-action: auto;
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 255, 255, 0.62), transparent 44%),
    linear-gradient(145deg, #e7e0d4, #ece7dd);
  scrollbar-width: thin;
  scrollbar-color: rgba(24, 35, 30, 0.24) transparent;
}

.editor-page-wrap {
  position: relative;
  flex: none;
  margin: auto;
  transition: width 180ms ease, height 180ms ease;
}

/* 放大到超出可视区后，flex 居中的负剩余空间会把页面的左/上边缘推到滚动
   范围之外（scrollLeft 最小是 0，滚到底也看不到），所以按轴改成左上对齐。
   两个轴分开判断：只有竖向溢出时保持横向居中，否则页面会横着跳一下，
   滚轮缩放的基点就跟着漂了 */
.editor-viewport.is-overflow-x {
  justify-content: flex-start;
}

.editor-viewport.is-overflow-x .editor-page-wrap {
  margin-left: 0;
  margin-right: 0;
}

.editor-viewport.is-overflow-y {
  align-items: flex-start;
}

.editor-viewport.is-overflow-y .editor-page-wrap {
  margin-top: 0;
  margin-bottom: 0;
}

.editor-viewport.is-zoomed {
  /* 放大后手指动作归我们处理，否则浏览器会抢去滚动手势 */
  touch-action: none;
}

.editor-viewport.is-panning {
  cursor: grabbing;
  -webkit-user-select: none;
  user-select: none;
}

/* 放大后左键直接拖动画面，光标要跟着变成抓手；落在文本框、图形、图片上
   仍然是编辑语义（可拖、可点、可选字），所以单独把光标还回去 */
.editor-viewport.is-zoomed,
.editor-viewport.is-zoomed .editor-page,
.editor-viewport.is-zoomed .editor-page-content {
  cursor: grab;
}

.editor-viewport.is-zoomed .tb {
  cursor: default;
}

.editor-viewport.is-zoomed .tb.shape {
  cursor: move;
}

.editor-viewport.is-zoomed .tb-text {
  cursor: text;
}

.editor-viewport.is-zoomed .editor-page-content img {
  cursor: pointer;
}

/* 按住空格时光标变抓手，提示「这里可以拖」 */
.editor-viewport.is-pan-ready,
.editor-viewport.is-pan-ready .editor-page {
  cursor: grab;
}

.editor-viewport.is-panning .editor-page {
  cursor: grabbing;
}

/* 捏合过程中手指已经接管，关掉尺寸过渡避免跟手时发飘 */
.editor-viewport.is-pinching .editor-page-wrap {
  transition: none;
}

/* 首次放大的操作提示，浮在编辑区底部中间 */
.editor-zoom-hint {
  position: absolute;
  left: 50%;
  bottom: 52px;
  z-index: 6;
  padding: 7px 14px;
  border: 1px solid rgba(24, 35, 30, 0.14);
  border-radius: 999px;
  background: rgba(24, 35, 30, 0.86);
  color: #f7f3ea;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 200ms ease, transform 200ms ease;
}

.editor-zoom-hint.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.editor-page {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 26px 56px -30px rgba(20, 28, 23, 0.65), 0 2px 4px rgba(20, 28, 23, 0.08);
  transform-origin: top left;
}

.editor-page-base {
  position: absolute;
  z-index: 0;
  display: block;
  max-width: none;
  pointer-events: none;
  user-select: none;
}

.editor-page-content {
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 54px 56px;
  overflow: hidden;
  outline: none;
  color: #19231e;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.editor-page-content:focus {
  box-shadow: inset 0 0 0 2px rgba(184, 75, 49, 0.22);
}

/* 超链接：页面图里要看得出来能点，所以给颜色 + 下划线（html2canvas 也认这两个属性） */
.editor-page-content a {
  color: #1d5c48;
  text-decoration: underline;
  text-decoration-color: rgba(29, 92, 72, 0.5);
  text-underline-offset: 2px;
  cursor: pointer;
}

.editor-page-content a:hover {
  text-decoration-color: currentColor;
}

.editor-page.has-base .editor-page-content:focus {
  box-shadow: inset 0 0 0 2px rgba(184, 75, 49, 0.28);
}

.editor-page-content p,
.editor-page-content div {
  margin: 0 0 0.9em;
}

.editor-page-content > :first-child {
  margin-top: 0;
}

.editor-page-content > :last-child {
  margin-bottom: 0;
}

.editor-page-content h1,
.editor-page-content h2,
.editor-page-content h3,
.editor-page-content h4 {
  margin: 0.7em 0 0.42em;
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.22;
}

.editor-page-content h1 {
  font-size: 42px;
}

.editor-page-content h2 {
  font-size: 34px;
}

.editor-page-content h3 {
  font-size: 24px;
}

.editor-page-content h4 {
  font-size: 19px;
}

.editor-page-content ul,
.editor-page-content ol {
  margin: 0 0 1em;
  padding-left: 1.35em;
}

.editor-page-content li {
  margin: 0.25em 0;
}

.editor-page-content blockquote {
  margin: 1.1em 0;
  padding: 0.1em 0 0.1em 1em;
  border-left: 2px solid var(--accent);
  color: var(--ink-soft);
  font-size: 17px;
  font-style: italic;
}

.editor-page-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.8em auto;
}

.editor-page-content hr {
  margin: 1.4em 0;
  border: 0;
  border-top: 1px solid rgba(24, 35, 30, 0.28);
}

.editor-page-content table {
  width: 100%;
  margin: 0.8em 0;
  border-collapse: collapse;
  font-size: 13px;
}

.editor-page-content th,
.editor-page-content td {
  padding: 6px 8px;
  border: 1px solid rgba(24, 35, 30, 0.24);
  text-align: left;
  vertical-align: top;
}

.editor-page-content pre {
  margin: 0.8em 0;
  padding: 10px 12px;
  overflow: hidden;
  background: rgba(24, 35, 30, 0.055);
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
}

.editor-page-content code {
  font-family: var(--mono);
  font-size: 0.9em;
}

.editor-page-content ::selection {
  color: var(--paper-hi);
  background: var(--accent);
}

.editor-empty-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 16px;
  border: 1px solid rgba(24, 35, 30, 0.1);
  background: rgba(250, 247, 240, 0.72);
  color: var(--faint);
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.03em;
  pointer-events: none;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.editor-page.has-base .editor-empty-hint {
  top: auto;
  right: 22px;
  bottom: 22px;
  left: auto;
  align-items: flex-end;
  background: rgba(250, 247, 240, 0.86);
  transform: none;
}

.editor-empty-hint span {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.12em;
}

.editor-status {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 15px;
  border-top: 1px solid var(--line);
  background: rgba(250, 247, 240, 0.72);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.06em;
}

.editor-status b {
  color: var(--muted);
  font-weight: 500;
}

.editor-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(233, 227, 216, 0.84);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  backdrop-filter: blur(3px);
}

.editor-loading p {
  margin: 0;
}

.editor-loading-line {
  width: 110px;
  height: 1px;
  overflow: hidden;
  background: rgba(24, 35, 30, 0.16);
}

.editor-loading-line::after {
  content: "";
  display: block;
  width: 45%;
  height: 100%;
  background: var(--accent);
  animation: editorLoading 1.1s ease-in-out infinite;
}

@keyframes editorLoading {
  from { transform: translateX(-110%); }
  to { transform: translateX(250%); }
}

.editor-footer {
  padding: 12px 22px;
}

.editor-footer .modal-footer-note {
  max-width: 58%;
  line-height: 1.6;
}

.editor-modal.is-busy .editor-toolbar,
.editor-modal.is-busy .editor-page-list,
.editor-modal.is-busy .editor-page-actions {
  pointer-events: none;
  opacity: 0.5;
}

.editor-modal.is-busy .editor-page-content {
  opacity: 0.82;
}

.editor-modal.is-loading .editor-sidebar {
  opacity: 0.72;
}

.editor-export-host {
  position: fixed;
  top: 0;
  left: -12000px;
  z-index: -10;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
}

.editor-export-page {
  box-shadow: none;
}

.editor-export-page .editor-page-content {
  box-shadow: none;
}

/* Header actions */

.editor-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-ghost {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 29px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(250, 247, 240, 0.55);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 9px;
  line-height: 1;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.editor-ghost [data-icon] {
  font-size: 12px;
}

.editor-ghost:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(24, 35, 30, 0.045);
}

.editor-ghost[aria-pressed="true"] {
  border-color: rgba(184, 75, 49, 0.32);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.editor-ghost:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* Sidebar extras */

.editor-side-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.editor-mini-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.editor-mini-narrow {
  width: 68px;
}

.editor-mini-field > span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
}

.editor-mini-field select,
.editor-select {
  min-width: 0;
  height: 26px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 9px;
  line-height: 1;
}

.editor-mini-field input[type="color"] {
  width: 100%;
  height: 26px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
}

.editor-mini-field input[type="number"] {
  min-width: 0;
  width: 100%;
  height: 26px;
  padding: 0 2px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.editor-mini-field input[type="number"]::-webkit-outer-spin-button,
.editor-mini-field input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}

.editor-mini-field input[type="number"]:focus {
  border-color: rgba(184, 75, 49, 0.45);
  outline: none;
}

.editor-mini-field input[type="number"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.editor-toolbar .editor-select {
  height: 25px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.editor-toolbar .editor-select:hover {
  border-color: var(--line);
  background: rgba(250, 247, 240, 0.75);
  color: var(--ink);
}

.editor-toolbar .editor-select-xs {
  min-width: 44px;
}

.editor-swatch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 29px;
  height: 29px;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.editor-swatch:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(24, 35, 30, 0.045);
}

.editor-swatch input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.editor-swatch-face {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
}

.editor-swatch.is-fill .editor-swatch-face {
  padding: 1px 3px;
  background: var(--accent-soft);
}

/* Page list rows */

.editor-page-row {
  position: relative;
}

.editor-page-row.is-dragging {
  opacity: 0.45;
}

.editor-page-row.is-drop-before::before,
.editor-page-row.is-drop-after::after {
  content: "";
  position: absolute;
  right: 4px;
  left: 4px;
  height: 2px;
  background: var(--accent);
}

.editor-page-row.is-drop-before::before {
  top: -1px;
}

.editor-page-row.is-drop-after::after {
  bottom: -1px;
}

.editor-page-item {
  cursor: grab;
}

/* Free text box */

.editor-page-content .tb {
  position: absolute;
  z-index: 3;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  /* 高度由 min-height 控制，文字变多时自动向下生长，不会藏字 */
  height: auto;
  cursor: default;
}

.editor-page-content .tb:hover {
  outline: 1px dashed rgba(184, 75, 49, 0.5);
  outline-offset: 1px;
}

.editor-page-content .tb-text {
  min-height: 1.2em;
  margin: 0;
  outline: none;
  overflow-wrap: anywhere;
}

.editor-page-content .tb-text:focus {
  outline: none;
}

/* 直线与色块：和文本框共用选中框，但没有内边距和文字，
   颜色走行内 background-color，才能一起被 html2canvas 画进页面图 */
.editor-page-content .tb.shape {
  padding: 0;
  border: 0;
  cursor: move;
  -webkit-user-select: none;
  user-select: none;
}

.editor-page-content .tb.shape:hover {
  outline: 1px dashed rgba(184, 75, 49, 0.5);
  outline-offset: 2px;
}

/* 页面视频：框里放的是首帧海报（页面图与 PDF 用的就是它），
   真正的 <video> 由阅读器叠在这个位置上播放 */
.editor-page-content .tb.video {
  padding: 0;
  overflow: hidden;
  border-radius: 3px;
  background: #0d1210;
  cursor: move;
  -webkit-user-select: none;
  user-select: none;
}

.editor-page-content .tb.video:hover {
  outline: 1px dashed rgba(184, 75, 49, 0.6);
  outline-offset: 2px;
}

.editor-page-content .tb.video .video-poster {
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.editor-page-content .tb.video .video-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(12, 18, 15, 0.55);
  text-align: center;
  line-height: 50px;
  pointer-events: none;
}

/* 播放三角用边框画：页面里没有文字节点，不会污染 PDF 文字层 */
.editor-page-content .tb.video .video-caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 4px;
  border-left: 14px solid #fff;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  vertical-align: middle;
}

/* Selection frame lives inside the content so it scales with the page,
   but it carries data-box-ui and is stripped before serializing. */
.editor-page-content .tb-frame {
  position: absolute;
  z-index: 40;
  outline: 1px solid var(--accent);
  outline-offset: 0;
  pointer-events: none;
}

.editor-page-content .tb-frame.is-dragging {
  outline-style: dashed;
}

/* 抓手位置由 JS 按可见区域计算后写成行内样式，这里只保留外观 */

.editor-page-content .tb-grip,
.editor-page-content .tb-h {
  position: absolute;
  pointer-events: auto;
}

.editor-page-content .tb-grip {
  display: grid;
  place-items: center;
  z-index: 3;
  width: 15px;
  height: 15px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: #fff;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1;
  cursor: grab;
  user-select: none;
}

.editor-page-content .tb-grip:active {
  cursor: grabbing;
}

.editor-page-content .tb-h {
  z-index: 2;
  width: 11px;
  height: 11px;
  border: 1px solid var(--accent);
  background: #fff;
}

.editor-page-content .tb-h[data-box-resize="nw"] { top: -6px; left: -6px; cursor: nwse-resize; }
.editor-page-content .tb-h[data-box-resize="n"]  { top: -6px; left: calc(50% - 5px); cursor: ns-resize; }
.editor-page-content .tb-h[data-box-resize="ne"] { top: -6px; right: -6px; cursor: nesw-resize; }
.editor-page-content .tb-h[data-box-resize="e"]  { top: calc(50% - 5px); right: -6px; cursor: ew-resize; }
.editor-page-content .tb-h[data-box-resize="se"] { right: -6px; bottom: -6px; cursor: nwse-resize; }
.editor-page-content .tb-h[data-box-resize="s"]  { bottom: -6px; left: calc(50% - 5px); cursor: ns-resize; }
.editor-page-content .tb-h[data-box-resize="sw"] { bottom: -6px; left: -6px; cursor: nesw-resize; }
.editor-page-content .tb-h[data-box-resize="w"]  { top: calc(50% - 5px); left: -6px; cursor: ew-resize; }

/* Box bar */

.editor-box-bar {
  position: absolute;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: rgba(250, 247, 240, 0.96);
  box-shadow: 0 10px 22px -14px rgba(20, 28, 23, 0.6);
  transform: translate(-50%, -100%);
  /* 手机上窄屏时宁可横向滚，也不要把「颜色」「置顶」拆成两行 */
  white-space: nowrap;
  max-width: calc(100vw - 16px);
  overflow-x: auto;
}

.editor-box-bar.is-below {
  transform: translate(-50%, 0);
}

.editor-box-bar .editor-num {
  width: 42px;
  height: 22px;
  padding: 0 4px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 9px;
  text-align: right;
}

.editor-box-bar .editor-num:focus {
  border-color: var(--accent);
  outline: none;
}

.editor-box-bar button {
  min-width: 24px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
}

.editor-box-bar button:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(24, 35, 30, 0.045);
}

.editor-box-bar button.is-danger:hover {
  border-color: rgba(184, 75, 49, 0.4);
  background: rgba(184, 75, 49, 0.12);
  color: var(--accent-deep);
}

/* 图形取色器要跟操作条上的 22px 控件齐平 */
.editor-box-bar .editor-swatch {
  width: 22px;
  height: 22px;
}

.editor-box-bar .editor-swatch-face {
  font-size: 10px;
}

.editor-box-bar .editor-swatch.is-fill .editor-swatch-face {
  padding: 0;
  background: transparent;
}

/* Draft restore bar */

.editor-draft-bar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(184, 75, 49, 0.28);
  background: rgba(234, 212, 199, 0.62);
  color: var(--accent-deep);
}

.editor-draft-copy {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.editor-draft-copy strong {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.editor-draft-copy span {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.editor-draft-actions {
  display: flex;
  flex: none;
  gap: 6px;
}

.editor-draft-actions button {
  height: 22px;
  padding: 0 9px;
  border: 1px solid rgba(184, 75, 49, 0.4);
  border-radius: 0;
  background: rgba(250, 247, 240, 0.8);
  color: var(--accent-deep);
  font-family: var(--sans);
  font-size: 9px;
  line-height: 1;
}

.editor-draft-actions button:hover {
  background: var(--paper-hi);
}

/* Image floating toolbar */

.editor-image-bar {
  position: absolute;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: rgba(250, 247, 240, 0.96);
  box-shadow: 0 10px 22px -14px rgba(20, 28, 23, 0.6);
  transform: translate(-50%, -100%);
}

.editor-image-bar.is-below {
  transform: translate(-50%, 0);
}

.editor-image-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.editor-image-group + .editor-image-group {
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.editor-image-label {
  margin-right: 2px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.08em;
}

.editor-image-bar button {
  min-width: 24px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
}

.editor-image-bar button:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(24, 35, 30, 0.045);
}

.editor-image-bar button.is-danger:hover {
  border-color: rgba(184, 75, 49, 0.4);
  background: rgba(184, 75, 49, 0.12);
  color: var(--accent-deep);
}

/* Status bar */

.editor-status-meta {
  color: var(--muted);
}

.editor-status-meta.is-warning {
  color: var(--accent-deep);
}

.editor-zoom {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 1px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.66);
}

.editor-zoom button {
  min-width: 26px;
  height: 21px;
  padding: 0 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
}

.editor-zoom button:hover {
  color: var(--ink);
  background: rgba(24, 35, 30, 0.09);
}

.editor-zoom button:active {
  background: rgba(24, 35, 30, 0.16);
}

.editor-zoom #editorZoomValue {
  min-width: 46px;
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.editor-zoom #editorZoomValue:hover {
  color: var(--ink);
}

/* Preview mode */

.editor-modal.is-preview .editor-body {
  grid-template-columns: minmax(0, 1fr);
}

.editor-modal.is-preview .editor-sidebar,
.editor-modal.is-preview .editor-toolbar,
.editor-modal.is-preview .editor-draft-bar {
  display: none;
}

.editor-modal.is-preview .editor-page-content {
  box-shadow: none;
}

.editor-modal.is-preview .editor-empty-hint {
  display: none;
}

/* Page content extras */

.editor-page-content figure {
  margin: 0.9em 0;
}

.editor-page-content figcaption {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

/* Library entry */

.add-book.is-manual {
  background:
    radial-gradient(circle at 50% 16%, rgba(184, 75, 49, 0.09), transparent 46%),
    linear-gradient(145deg, rgba(250, 247, 240, 0.62), rgba(234, 212, 199, 0.18));
}

.add-book.is-manual .add-book-icon {
  border-radius: 4px;
}

.empty-shelf-actions {
  flex-wrap: wrap;
  row-gap: 14px;
}

@media (max-width: 1000px) {
  .editor-body {
    grid-template-columns: 218px minmax(0, 1fr);
  }

  .editor-card {
    width: calc(100vw - 28px);
    height: calc(100dvh - 28px);
    max-height: calc(100dvh - 28px);
  }

  .editor-head {
    padding: 17px 20px 14px;
  }

  .editor-page-content {
    padding: 42px 44px;
  }

  .editor-tool-group {
    padding-right: 4px;
  }
}

@media (max-width: 760px) {
  .editor-modal[open] {
    padding: 0;
  }

  .editor-card {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
  }

  .editor-head {
    padding: 13px 15px 11px;
  }

  .editor-head-note {
    display: none;
  }

  .editor-head h2 {
    font-size: 22px;
  }

  .editor-head .modal-close {
    width: 33px;
    height: 33px;
  }

  .editor-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .editor-sidebar {
    display: block;
    padding: 10px 13px 9px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .editor-title-field input {
    font-size: 18px;
  }

  .editor-pages-head {
    align-items: center;
    margin-top: 9px;
    padding-top: 9px;
  }

  .editor-pages-head .modal-kicker {
    display: none;
  }

  .editor-pages-head strong {
    font-size: 14px;
  }

  .editor-page-list {
    display: flex;
    gap: 6px;
    margin: 7px -3px 0;
    padding: 0 3px 2px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .editor-page-item {
    flex: none;
    width: auto;
    padding: 4px;
  }

  .editor-page-thumb {
    width: 38px;
  }

  .editor-page-copy {
    display: none;
  }

  .editor-side-note {
    display: none;
  }

  .editor-toolbar {
    flex-wrap: nowrap;
    padding: 7px 8px;
    overflow-x: auto;
  }

  .editor-tool-group {
    flex: none;
  }

  .editor-tool-group-end {
    margin-left: 0;
  }

  .editor-viewport {
    padding: 10px;
  }

  .editor-page-content {
    padding: 36px 38px;
  }

  .editor-status {
    padding: 7px 10px;
  }

  /* 手机上缩放按钮要够大才好点，放大后靠它看细节 */
  .editor-zoom button {
    min-width: 34px;
    height: 26px;
    font-size: 11px;
  }

  .editor-zoom #editorZoomValue {
    min-width: 52px;
  }

  .editor-status span:last-child {
    display: none;
  }

  .editor-footer {
    padding: 9px 12px;
  }

  .editor-footer .modal-footer-note {
    display: none;
  }

  .editor-footer .modal-footer-actions {
    width: 100%;
  }

  .editor-footer .btn {
    flex: 1;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .editor-page-wrap {
    transition: none;
  }

  .editor-loading-line::after {
    animation: none;
    transform: translateX(60%);
  }
}
