.document-editor-dialog {
  background: #0a111c;
  border: 1px solid rgba(142, 157, 185, .24);
  border-radius: 22px;
  color: var(--text);
  height: min(920px, calc(100vh - 36px));
  margin: auto;
  max-height: none;
  max-width: none;
  padding: 0;
  width: min(1480px, calc(100vw - 36px));
}

.document-editor-dialog::backdrop {
  backdrop-filter: blur(12px);
  background: rgba(2, 7, 14, .78);
}

.document-editor-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.document-editor-head {
  align-items: center;
  background: rgba(13, 22, 35, .96);
  border-bottom: 1px solid rgba(142, 157, 185, .18);
  display: grid;
  gap: 14px;
  grid-template-columns: auto minmax(180px, 1fr) auto auto;
  padding: 13px 16px;
}

#document-editor-title {
  background: transparent;
  border: 0;
  color: #f5f7fb;
  font-size: 1.05rem;
  font-weight: 750;
  min-width: 0;
  outline: 0;
  padding: 8px 10px;
}

#document-editor-title:focus {
  background: rgba(124, 108, 255, .08);
  border-radius: 10px;
}

.document-save-status {
  color: #86e7c0;
  font-size: .75rem;
  min-width: 84px;
  text-align: right;
}

.document-save-status.saving {
  color: #b9c5d8;
}

.document-save-status.error {
  color: #ff8993;
}

.document-mode-switch,
.document-side-tabs {
  background: rgba(5, 12, 21, .64);
  border: 1px solid rgba(142, 157, 185, .18);
  border-radius: 12px;
  display: flex;
  padding: 3px;
}

.document-mode-switch button,
.document-side-tabs button {
  background: transparent;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  padding: 8px 11px;
}

.document-mode-switch button.active,
.document-side-tabs button.active {
  background: rgba(124, 108, 255, .17);
  color: #f2f0ff;
}

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

.document-canvas {
  background:
    radial-gradient(circle at 50% 15%, rgba(124, 108, 255, .07), transparent 34%),
    #0b131f;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
}

.document-format-toolbar {
  align-items: center;
  background: rgba(13, 22, 35, .84);
  border-bottom: 1px solid rgba(142, 157, 185, .14);
  display: flex;
  gap: 7px;
  padding: 10px max(20px, calc((100% - 820px) / 2));
}

.document-format-toolbar > span {
  flex: 1;
}

.document-format-toolbar button {
  background: rgba(21, 33, 51, .8);
  border: 1px solid rgba(142, 157, 185, .17);
  border-radius: 9px;
  color: #dce5f2;
  min-height: 34px;
  padding: 6px 10px;
}

#document-editor-body-input,
.document-reader {
  background: rgba(14, 23, 36, .9);
  border: 1px solid rgba(142, 157, 185, .16);
  border-radius: 4px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .22);
  color: #e9edf5;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.75;
  margin: 24px auto;
  max-width: 820px;
  min-height: calc(100% - 48px);
  overflow: auto;
  padding: clamp(28px, 5vw, 68px);
  resize: none;
  width: calc(100% - 40px);
}

#document-editor-body-input:focus {
  border-color: rgba(124, 108, 255, .5);
  outline: 0;
}

.document-reader h1,
.document-reader h2,
.document-reader h3 {
  color: #fff;
  line-height: 1.25;
  margin: 1.4em 0 .55em;
}

.document-reader h1:first-child,
.document-reader h2:first-child {
  margin-top: 0;
}

.document-reader p,
.document-reader ul {
  margin: 0 0 1em;
}

.document-reader blockquote {
  border-left: 3px solid #7c6cff;
  color: #b9c5d8;
  margin: 1em 0;
  padding-left: 16px;
}

.document-editor-footer {
  align-items: center;
  border-top: 1px solid rgba(142, 157, 185, .13);
  color: var(--muted);
  display: flex;
  font-size: .72rem;
  justify-content: space-between;
  padding: 9px 22px;
}

.document-side-panel {
  background: #0d1725;
  border-left: 1px solid rgba(142, 157, 185, .18);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding: 14px;
}

.document-side-tabs {
  margin-bottom: 13px;
}

.document-side-tabs button {
  flex: 1;
}

.document-side-tabs span {
  align-items: center;
  background: rgba(124, 108, 255, .24);
  border-radius: 999px;
  display: inline-flex;
  font-size: .68rem;
  height: 20px;
  justify-content: center;
  margin-left: 4px;
  min-width: 20px;
}

.document-panel {
  min-height: 0;
  overflow: auto;
}

#document-comment-form {
  background: rgba(17, 29, 46, .9);
  border: 1px solid rgba(142, 157, 185, .18);
  border-radius: 14px;
  display: grid;
  gap: 9px;
  margin-bottom: 14px;
  padding: 12px;
}

#document-comment-form textarea {
  min-height: 76px;
  resize: vertical;
}

#document-comment-form > div:last-child {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.document-comment-context {
  background: rgba(124, 108, 255, .1);
  border-left: 2px solid #7c6cff;
  border-radius: 7px;
  color: #c8c1ff;
  font-size: .75rem;
  line-height: 1.45;
  padding: 8px 9px;
}

.document-comments-list,
.document-revisions-list {
  display: grid;
  gap: 10px;
}

.document-comment {
  background: rgba(17, 29, 46, .78);
  border: 1px solid rgba(142, 157, 185, .16);
  border-radius: 14px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.document-comment.reply {
  margin-left: 22px;
}

.document-comment.resolved {
  opacity: .65;
}

.document-comment header,
.document-comment footer,
.document-revision-card header {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.document-comment header span,
.document-comment footer,
.document-comment time,
.document-revision-card small {
  color: var(--muted);
  font-size: .7rem;
}

.document-comment blockquote {
  border-left: 2px solid #7c6cff;
  color: #aeb9cb;
  font-size: .75rem;
  margin: 0;
  overflow: hidden;
  padding-left: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-comment p {
  line-height: 1.5;
  margin: 0;
}

.document-comment footer {
  justify-content: flex-start;
}

.document-comment footer button {
  font-size: .7rem;
  padding: 3px 0;
}

.document-revision-card {
  background: rgba(17, 29, 46, .78);
  border: 1px solid rgba(142, 157, 185, .16);
  border-radius: 14px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.document-revision-card p {
  color: #aeb9cb;
  font-size: .75rem;
  line-height: 1.5;
  margin: 0;
  max-height: 4.5em;
  overflow: hidden;
}

@media (max-width: 920px) {
  .document-editor-dialog {
    border-radius: 0;
    height: 100vh;
    width: 100vw;
  }

  .document-editor-head {
    grid-template-columns: auto minmax(120px, 1fr) auto;
  }

  .document-mode-switch {
    grid-column: 1 / -1;
  }

  .document-editor-body {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .document-canvas {
    min-height: 72vh;
  }

  .document-side-panel {
    border-left: 0;
    border-top: 1px solid rgba(142, 157, 185, .18);
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .document-format-toolbar {
    overflow-x: auto;
    padding: 8px 12px;
  }

  #document-editor-body-input,
  .document-reader {
    border-left: 0;
    border-right: 0;
    margin: 10px 0;
    min-height: calc(100% - 20px);
    padding: 24px 18px;
    width: 100%;
  }
}
