/* Document editor */

.doc-editor { position: relative; background: var(--bg-2); }
.doc-editor .doc-toolbar { gap: 2px; padding: 6px 12px; }

.doc-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-x: auto;
  padding: 26px 24px 90px;
  background-color: var(--bg-2);
  background-image: radial-gradient(rgba(120, 130, 160, .16) 0.7px, transparent 0.7px);
  background-size: 18px 18px;
  scroll-behavior: smooth;
}
html[data-theme="light"] .doc-scroll { background-image: radial-gradient(rgba(40, 50, 80, .12) 0.7px, transparent 0.7px); }

.page-wrap {
  position: relative;
  width: fit-content;
  margin: 0 auto 40px;
  transform-origin: top center;
  transition: width 200ms var(--ease);
}

.doc-empty-hint {
  position: absolute;
  inset: 0;
  padding: 72px 82px;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.72;
  color: #a0a2ae;
  pointer-events: none;
  z-index: 1;
}
.doc-empty-hint[hidden] { display: none; }

.page {
  width: 794px;
  min-height: 1123px;
  padding: 72px 82px 88px;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 3px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, .2),
    0 26px 60px -28px rgba(0, 0, 0, .55),
    0 0 0 1px rgba(0, 0, 0, .04);
  outline: none;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.72;
  letter-spacing: .002em;
  caret-color: #5b45d6;
  word-wrap: break-word;
}
.doc-editor.is-wide .page { width: 1040px; }
.page:focus { box-shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 30px 70px -30px rgba(0, 0, 0, .6), 0 0 0 1px rgba(124, 92, 255, .25); }

.page ::selection { background: rgba(124, 92, 255, .22); color: inherit; }

.page p { margin: 0 0 13px; }
.page h1, .page h2, .page h3 {
  font-family: var(--font-ui);
  color: #111319;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.page h1 { font-size: 34px; font-weight: 700; margin: 0 0 14px; }
.page h2 { font-size: 21px; font-weight: 660; margin: 30px 0 10px; }
.page h3 { font-size: 17px; font-weight: 640; margin: 22px 0 8px; }
.page .doc-title { font-size: 40px; line-height: 1.1; letter-spacing: -.035em; margin: 0 0 12px; }
.page .doc-meta {
  font-family: var(--font-ui);
  font-size: 11.5px; line-height: 1.5; letter-spacing: .015em;
  color: #6b7280;
  padding-bottom: 18px;
  margin: 0 0 22px;
  border-bottom: 1px solid #e8e8ef;
}
.page .doc-lede {
  font-size: 19px; line-height: 1.6; color: #34363f;
  border-left: 3px solid #7c5cff;
  padding: 2px 0 2px 18px;
  margin: 0 0 26px;
}
.page ul, .page ol { margin: 0 0 14px; padding-left: 26px; }
.page li { margin: 0 0 5px; }
.page li::marker { color: #8b7cff; }
.page blockquote {
  margin: 20px 0;
  padding: 14px 20px;
  border-left: 3px solid #7c5cff;
  background: #f7f6ff;
  border-radius: 0 6px 6px 0;
  color: #3a3d47;
  font-style: italic;
}
.page table { width: 100%; border-collapse: collapse; margin: 14px 0 20px; font-family: var(--font-ui); font-size: 13px; line-height: 1.5; }
.page table th { background: #f5f4fb; text-align: left; font-weight: 620; color: #24262e; }
.page table th, .page table td { border: 1px solid #e4e4ec; padding: 8px 10px; vertical-align: top; }
.page table tr:nth-child(even) td { background: #fcfcfe; }
.page pre {
  margin: 16px 0;
  padding: 14px 18px;
  background: #f5f6fa;
  border: 1px solid #e8e9f0;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: #2c2f3a;
}
.page code { font-family: var(--font-mono); font-size: .88em; background: #f1f2f7; border-radius: 4px; padding: 1px 5px; color: #5540c8; }
.page pre code { background: none; padding: 0; color: inherit; }
.page img { max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 10px 0; }
.page a { color: #5b45d6; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(91, 69, 214, .35); }
.page hr { border: 0; border-top: 1px solid #e4e4ec; margin: 24px 0; }
.page u { text-underline-offset: 3px; }

/* toolbar active states */
.doc-toolbar .fmt-bold.is-active,
.doc-toolbar .fmt-italic.is-active,
.doc-toolbar .fmt-underline.is-active,
.doc-toolbar .fmt-strike.is-active { color: #c3b2ff; background: var(--accent-soft); }
html[data-theme="light"] .doc-toolbar .fmt-bold.is-active,
html[data-theme="light"] .doc-toolbar .fmt-italic.is-active,
html[data-theme="light"] .doc-toolbar .fmt-underline.is-active,
html[data-theme="light"] .doc-toolbar .fmt-strike.is-active { color: #5b3ed6; }

/* focus mode */
.doc-editor.is-focus .doc-toolbar,
.doc-editor.is-focus .statusbar { display: none; }
.doc-editor.is-focus .doc-scroll { padding-top: 40px; }
.doc-editor.is-focus .page { box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6); }

/* find & replace */
.doc-findbar {
  position: absolute;
  top: 50px;
  right: 20px;
  z-index: 40;
  width: 372px;
  padding: 9px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: menuIn 140ms var(--ease);
}
.doc-findbar[hidden] { display: none; }
.find-row { display: flex; align-items: center; gap: 4px; padding: 2px 2px 2px 8px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); }
.find-row > span { color: var(--faint); display: grid; place-items: center; }
.find-row .i { width: 14px; height: 14px; }
.find-row input { flex: 1; min-width: 0; height: 28px; background: none; border: none; outline: none; font-size: 12.5px; }
.find-row .tb-btn { width: 26px; height: 26px; }
.find-count { font-size: 10.5px; color: var(--muted); padding: 0 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .doc-scroll { padding: 14px 8px 80px; }
  .page { width: 100%; padding: 40px 28px; min-height: 800px; }
  .doc-empty-hint { padding: 40px 28px; }
  .doc-editor.is-wide .page { width: 100%; }
  .doc-findbar { width: calc(100% - 20px); right: 10px; top: 52px; }
}
