/* Rich document editor v26: Feishu-like continuous editing, media, slash commands, and article preview. */

.rich-document-editor {
  grid-template-rows: 64px 52px minmax(0, 1fr);
}

.rich-document-location {
  max-width: 420px;
  min-width: 0;
}

.rich-document-location strong {
  overflow: hidden;
  max-width: 260px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rich-document-location small {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid #3d3030;
  color: #d86c6c;
  font-size: 11px;
}

.rich-editor-toolbar {
  z-index: 8;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  padding: 6px 18px 6px max(18px, calc((100vw - 1120px) / 2 + 238px));
  overflow-x: auto;
  border-bottom: 1px solid #303030;
  background: rgb(16 16 16 / 97%);
  scrollbar-width: thin;
}

.rich-editor-toolbar button,
.rich-style-select select {
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: #a9a9a9;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.rich-editor-toolbar button:hover,
.rich-editor-toolbar button:focus-visible,
.rich-style-select select:hover,
.rich-style-select select:focus-visible {
  border-color: #3e3e3e;
  background: #222222;
  color: #eeeeee;
  outline: 0;
}

.rich-editor-toolbar .rich-toolbar-text {
  padding: 0;
  font-size: 15px;
}

.rich-style-select select {
  min-width: 94px;
  border-color: #333333;
  background: #171717;
}

.rich-toolbar-divider {
  flex: 0 0 auto;
  width: 1px;
  height: 22px;
  margin: 0 5px;
  background: #343434;
}

.rich-toolbar-hint {
  margin-left: auto;
  color: #595959;
  font-size: 11px;
  white-space: nowrap;
}

.rich-editor-scroll {
  background:
    linear-gradient(90deg, transparent 49.95%, rgb(255 255 255 / 2%) 50%, transparent 50.05%),
    #090909;
}

.rich-editor-layout {
  grid-template-columns: 220px minmax(0, 860px);
  gap: 32px;
  width: min(1150px, calc(100% - 48px));
  padding-top: 28px;
}

.rich-editor-outline {
  top: 24px;
}

.rich-editor-outline nav button.subheading {
  padding-left: 18px;
  color: #727272;
}

.rich-editor-outline nav button.subheading span {
  opacity: 0.55;
}

.rich-document-paper {
  padding: 58px 76px 62px;
  background: #141414;
}

.rich-document-tip {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 28px 0 18px;
  padding: 13px 15px;
  border: 1px solid #343434;
  background: #101010;
}

.rich-document-tip > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #5a3737;
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
}

.rich-document-tip p {
  margin: 0;
  color: #787878;
  font-size: 12px;
  line-height: 1.65;
}

.rich-document-tip strong {
  display: block;
  color: #bbbbbb;
  font-size: 13px;
}

.rich-editor-surface {
  min-height: 780px;
  padding: 2px 0 80px;
  color: #d4d4d4;
  font-size: 18px;
  line-height: 1.9;
  outline: 0;
  overflow-wrap: anywhere;
}

.rich-editor-surface > *:first-child {
  margin-top: 0;
}

.rich-editor-surface h2,
.rich-editor-surface h3,
.local-rich-article h2,
.local-rich-article h3 {
  color: #f0f0f0;
  font-family: var(--font-heading);
  font-weight: 640;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.rich-editor-surface h2,
.local-rich-article h2 {
  margin: 58px 0 18px;
  padding-top: 6px;
  font-size: 27px;
}

.rich-editor-surface h3,
.local-rich-article h3 {
  margin: 36px 0 14px;
  font-size: 21px;
}

.rich-editor-surface p,
.local-rich-article p {
  margin: 12px 0;
  color: #cecece;
  font-size: 18px;
  line-height: 1.9;
}

.rich-editor-surface p:focus,
.rich-editor-surface h2:focus,
.rich-editor-surface h3:focus,
.rich-editor-surface li:focus,
.rich-editor-surface blockquote:focus {
  outline: 0;
}

.rich-editor-surface p[data-placeholder]:has(> br:only-child)::before,
.rich-editor-surface li[data-placeholder]:has(> br:only-child)::before {
  color: #555555;
  content: attr(data-placeholder);
  pointer-events: none;
}

.rich-editor-surface ul,
.rich-editor-surface ol,
.local-rich-article ul,
.local-rich-article ol {
  display: grid;
  gap: 8px;
  margin: 16px 0 24px;
  padding-left: 28px;
}

.rich-editor-surface li,
.local-rich-article li {
  padding-left: 4px;
  color: #cecece;
  font-size: 18px;
  line-height: 1.8;
}

.rich-editor-surface li::marker,
.local-rich-article li::marker {
  color: #747474;
}

.rich-editor-surface blockquote,
.local-rich-article blockquote {
  margin: 24px 0;
  padding: 8px 0 8px 20px;
  border-left: 3px solid #777777;
  color: #b6b6b6;
  font-size: 18px;
  font-style: italic;
  line-height: 1.85;
}

.rich-editor-surface .doc-callout,
.local-rich-article .doc-callout {
  margin: 26px 0;
  padding: 18px 20px;
  border: 1px solid #4a3838;
  border-left: 3px solid var(--brand);
  background: linear-gradient(100deg, rgb(255 77 77 / 7%), transparent 60%), #111111;
}

.rich-editor-surface .doc-callout > strong,
.local-rich-article .doc-callout > strong {
  color: #ee8585;
  font-size: 13px;
}

.rich-editor-surface .doc-callout p,
.local-rich-article .doc-callout p {
  margin: 7px 0 0;
  color: #bdbdbd;
  font-size: 17px;
  line-height: 1.75;
}

.rich-editor-surface hr,
.local-rich-article hr {
  height: 1px;
  margin: 42px 0;
  border: 0;
  background: #383838;
}

.rich-editor-surface a,
.local-rich-article a {
  color: #ef8585;
  text-decoration: underline;
  text-decoration-color: rgb(239 133 133 / 45%);
  text-underline-offset: 4px;
}

.rich-editor-surface code,
.local-rich-article code {
  padding: 2px 6px;
  border: 1px solid #3a3a3a;
  background: #0d0d0d;
  color: #e1e1e1;
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.rich-editor-surface pre,
.local-rich-article pre {
  overflow-x: auto;
  margin: 24px 0;
  padding: 18px 20px;
  border: 1px solid #363636;
  background: #0d0d0d;
  color: #d5d5d5;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre;
}

.rich-editor-surface figure.doc-image,
.local-rich-article figure.doc-image {
  margin: 30px 0;
}

.rich-editor-surface figure.doc-image img,
.local-rich-article figure.doc-image img {
  display: block;
  width: 100%;
  max-height: 680px;
  border: 1px solid #3b3b3b;
  background: #0b0b0b;
  object-fit: contain;
}

.rich-editor-surface figure.doc-image figcaption,
.local-rich-article figure.doc-image figcaption {
  margin-top: 10px;
  color: #777777;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.rich-editor-surface figure.doc-image figcaption:focus {
  color: #bdbdbd;
  outline: 0;
}

.rich-editor-surface.is-dragging {
  outline: 2px dashed var(--brand);
  outline-offset: 14px;
  background: rgb(255 77 77 / 3%);
}

.rich-slash-menu {
  position: fixed;
  z-index: 100;
  width: 280px;
  max-height: min(420px, calc(100vh - 110px));
  padding: 7px;
  overflow-y: auto;
  border: 1px solid #454545;
  background: #171717;
  box-shadow: 0 22px 70px rgb(0 0 0 / 60%);
}

.rich-slash-menu header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 0 9px;
  border-bottom: 1px solid #303030;
}

.rich-slash-menu header strong {
  color: #d4d4d4;
  font-size: 12px;
}

.rich-slash-menu header small {
  color: #686868;
  font-size: 10px;
}

.rich-slash-menu button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 52px;
  align-items: center;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: var(--font-body);
  text-align: left;
}

.rich-slash-menu button:hover,
.rich-slash-menu button:focus-visible {
  background: #242424;
  outline: 0;
}

.rich-slash-menu button > span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid #404040;
  color: #b5b5b5;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
}

.rich-slash-menu button > div {
  display: grid;
  gap: 2px;
}

.rich-slash-menu button strong {
  color: #d3d3d3;
  font-size: 12px;
}

.rich-slash-menu button small {
  color: #696969;
  font-size: 10px;
}

.rich-link-popover {
  position: fixed;
  z-index: 110;
  top: 120px;
  left: 50%;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 8px;
  width: min(520px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid #454545;
  background: #171717;
  box-shadow: 0 20px 70px rgb(0 0 0 / 58%);
  transform: translateX(-50%);
}

.rich-link-popover label {
  display: grid;
  gap: 5px;
}

.rich-link-popover label span {
  color: #7e7e7e;
  font-size: 10px;
}

.rich-link-popover input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid #3c3c3c;
  background: #0d0d0d;
  color: #dddddd;
  font-family: var(--font-body);
  font-size: 12px;
  outline: 0;
}

.rich-link-popover input:focus {
  border-color: #777777;
}

.rich-link-popover input.is-invalid {
  border-color: var(--brand);
}

.rich-link-popover button {
  align-self: end;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #3f3f3f;
  background: #222222;
  color: #d5d5d5;
  font-family: var(--font-body);
  font-size: 11px;
}

.rich-link-popover [data-rich-link-apply] {
  border-color: var(--brand);
  background: var(--brand);
  color: #101010;
  font-weight: 700;
}

.rich-document-footer {
  margin-top: 24px;
  border-top: 1px solid #333333;
}

.draft-save-status.error,
.draft-save-status.error i {
  color: #ef7777;
}

.draft-save-status.error i {
  background: var(--brand);
}

.local-workflow-article .workflow-article-hero {
  border-radius: 0;
  border-left-color: var(--brand);
  background: linear-gradient(115deg, rgb(255 77 77 / 9%), transparent 62%), #151515;
}

.local-rich-article-body {
  gap: 48px;
}

.local-rich-article {
  min-width: 0;
}

.local-rich-article > h2:first-child {
  margin-top: 0;
}

.local-rich-article figure.doc-image img {
  border-radius: 0;
}

@media (min-width: 1440px) {
  .rich-document-editor {
    grid-template-rows: 72px 52px minmax(0, 1fr);
  }
}

@media (max-width: 1020px) {
  .rich-editor-toolbar {
    padding-inline: 16px;
  }

  .rich-editor-layout {
    grid-template-columns: 1fr;
    width: min(860px, calc(100% - 40px));
  }

  .rich-editor-outline {
    grid-template-columns: auto 1fr;
  }
}

@media (max-width: 720px) {
  .rich-document-editor {
    grid-template-rows: 58px 48px minmax(0, 1fr);
  }

  .rich-document-location,
  .rich-document-editor .draft-save-status {
    display: none;
  }

  .rich-document-editor .draft-editor-bar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .rich-document-editor .draft-editor-actions {
    justify-self: end;
  }

  .rich-document-editor .draft-editor-actions [data-draft-preview] {
    display: inline-flex;
    min-height: 36px;
    padding-inline: 10px;
    font-size: 11px;
  }

  .rich-editor-toolbar {
    gap: 2px;
    padding: 5px 10px;
  }

  .rich-editor-toolbar button,
  .rich-style-select select {
    min-width: 38px;
    min-height: 38px;
  }

  .rich-toolbar-hint {
    display: none;
  }

  .rich-editor-layout {
    width: min(100% - 20px, 640px);
    padding-top: 10px;
  }

  .rich-editor-outline {
    display: none;
  }

  .rich-document-paper {
    padding: 34px 22px 40px;
  }

  .rich-document-tip {
    margin-top: 22px;
  }

  .rich-editor-surface {
    min-height: 640px;
    font-size: 17px;
  }

  .rich-editor-surface h2,
  .local-rich-article h2 {
    margin-top: 46px;
    font-size: 24px;
  }

  .rich-editor-surface h3,
  .local-rich-article h3 {
    font-size: 20px;
  }

  .rich-editor-surface p,
  .rich-editor-surface li,
  .rich-editor-surface blockquote,
  .local-rich-article p,
  .local-rich-article li,
  .local-rich-article blockquote {
    font-size: 17px;
  }

  .rich-slash-menu {
    width: min(280px, calc(100vw - 24px));
  }

  .rich-link-popover {
    top: 116px;
    grid-template-columns: 1fr 1fr;
  }

  .rich-link-popover label {
    grid-column: 1 / -1;
  }

  .local-rich-article-body {
    gap: 34px;
  }

  .local-workflow-preview-frame .reader-bar-actions [data-local-preview-edit] {
    display: none;
  }

  .local-workflow-preview-frame .reader-bar-actions [data-local-preview-done] {
    width: auto;
    min-width: 64px;
    min-height: 36px;
    padding: 0 12px;
    color: var(--primary-foreground);
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rich-document-editor *,
  .local-workflow-preview-frame * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
