@import 'highlight.js/styles/an-old-hope.css';
@import 'katex/dist/katex.min.css';
@import 'react-photo-view/dist/react-photo-view.css';

:root {
  --common-row-font-size: 16px;
  --common-row-line-height: 1.625;
  --udtoken-quote-bar-bg: #bbbfc4;

  --table-head-background-color: #f2f3f5;
  --table-cell-border-color: #dee0e3;


  --mui-shape-borderRadius: 10px;
  --mui-spacing-unit: 8px;

  --mui-transitions-duration-short: 250ms;
  --mui-transitions-duration-standard: 300ms;
  --mui-transitions-easing-easeOut: cubic-bezier(0.0, 0, 0.2, 1);
  --mui-transitions-easing-easeInOut: cubic-bezier(0.4, 0, 0.2, 1);

  overflow-wrap: break-word;
  text-size-adjust: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  position: relative;
}

* {
  box-sizing: border-box;
}

.tiptap.ProseMirror {
  padding: 0.25rem;
}

.tiptap.ProseMirror a {
  text-decoration: none;
}

.tiptap.ProseMirror *:not(pre)>code {
  background-color: var(--mui-palette-background-paper3);
  border: 1px solid var(--mui-palette-divider);
  border-radius: 4px;
  font-size: 90%;
  white-space: break-spaces;
  word-break: break-word;
  overflow-wrap: break-word;
  padding: 0.125rem 0.25rem;
}

.tiptap.ProseMirror label:has(input[type="checkbox"]) {
  line-height: 1;
  padding-top: 0.5rem;
}

.tiptap.ProseMirror input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 1rem;
  height: 1rem;
  border: 1px solid;
  border-radius: 4px;
  background-color: var(--mui-palette-background-default);
  cursor: pointer;
  position: relative;
  transition: all var(--mui-transitions-duration-short) var(--mui-transitions-easing-easeOut);
}

.tiptap.ProseMirror input[type="checkbox"]:checked {
  background-color: var(--mui-palette-background-paper);
}

.tiptap.ProseMirror input[type="checkbox"]:checked::after {
  content: "";
  width: 70%;
  height: 70%;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--mui-palette-primary-main);
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22currentColor%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M21.4142%204.58579C22.1953%205.36683%2022.1953%206.63317%2021.4142%207.41421L10.4142%2018.4142C9.63317%2019.1953%208.36684%2019.1953%207.58579%2018.4142L2.58579%2013.4142C1.80474%2012.6332%201.80474%2011.3668%202.58579%2010.5858C3.36683%209.80474%204.63317%209.80474%205.41421%2010.5858L9%2014.1716L18.5858%204.58579C19.3668%203.80474%2020.6332%203.80474%2021.4142%204.58579Z%22%20fill%3D%22currentColor%22%2F%3E%3C%2Fsvg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22currentColor%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M21.4142%204.58579C22.1953%205.36683%2022.1953%206.63317%2021.4142%207.41421L10.4142%2018.4142C9.63317%2019.1953%208.36684%2019.1953%207.58579%2018.4142L2.58579%2013.4142C1.80474%2012.6332%201.80474%2011.3668%202.58579%2010.5858C3.36683%209.80474%204.63317%209.80474%205.41421%2010.5858L9%2014.1716L18.5858%204.58579C19.3668%203.80474%2020.6332%203.80474%2021.4142%204.58579Z%22%20fill%3D%22currentColor%22%2F%3E%3C%2Fsvg%3E") center/contain no-repeat;
}

.tiptap.ProseMirror input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--mui-palette-action-selected);
}

.tiptap.ProseMirror input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tiptap.ProseMirror input[type="checkbox"]:disabled:checked {
  background-color: var(--mui-palette-text-disabled);
  border-color: var(--mui-palette-text-disabled);
}

.tiptap.ProseMirror .react-renderer.node-flow {
  line-height: normal;
}

.tiptap.ProseMirror .react-renderer.node-image,
.tiptap.ProseMirror .react-renderer.node-inlineLink,
.tiptap.ProseMirror .react-renderer.node-inlineAttachment,
.tiptap.ProseMirror .react-renderer.node-inlineMath {
  display: inline-block;
  margin: 0 0.25rem;
}

.tiptap.ProseMirror .react-renderer.node-inlineMath,
.tiptap.ProseMirror .react-renderer.node-blockMath {
  user-select: none;
}

.tiptap.ProseMirror div[data-content-type="table"],
.tiptap.ProseMirror .react-renderer.node-alert,
.tiptap.ProseMirror .react-renderer.node-iframe,
.tiptap.ProseMirror .react-renderer.node-codeBlock,
.tiptap.ProseMirror .react-renderer.node-blockLink,
.tiptap.ProseMirror .react-renderer.node-flipGrid,
.tiptap.ProseMirror .react-renderer.node-audio,
.tiptap.ProseMirror .react-renderer.node-video,
.tiptap.ProseMirror .react-renderer.node-flow,
.tiptap.ProseMirror .react-renderer.node-blockMath,
.tiptap.ProseMirror .react-renderer.node-blockAttachment {
  display: block;
  margin: 1rem 0;
}

.tiptap.ProseMirror p :first-child:is(.react-renderer.node-image),
.tiptap.ProseMirror p :first-child:is(.react-renderer.node-inlineMath) {
  margin-left: 0;
}

.tiptap.ProseMirror .react-renderer.node-iframe,
.tiptap.ProseMirror .react-renderer.node-image,
.tiptap.ProseMirror .react-renderer.node-audio,
.tiptap.ProseMirror .react-renderer.node-video,
.tiptap.ProseMirror .react-renderer.node-blockAttachment,
.tiptap.ProseMirror .react-renderer.node-inlineAttachment,
.tiptap.ProseMirror .react-renderer.node-blockLink,
.tiptap.ProseMirror .react-renderer.node-inlineLink,
.tiptap.ProseMirror .react-renderer.node-excalidraw,
.tiptap.ProseMirror .react-renderer.node-blockMath,
.tiptap.ProseMirror .react-renderer.node-inlineMath {
  box-sizing: border-box;
  line-height: 1;
}

.tiptap.ProseMirror .image-wrapper img {
  line-height: 0;
}

.tiptap.ProseMirror .image-wrapper {
  display: inline-block;
}

.tiptap.ProseMirror .codeblock-wrapper.ProseMirror-selectednode>pre,
.tiptap.ProseMirror .audio-wrapper.ProseMirror-selectednode>div,
.tiptap.ProseMirror .video-wrapper.ProseMirror-selectednode>div,
.tiptap.ProseMirror .image-wrapper.ProseMirror-selectednode>span {
  border-color: var(--mui-palette-primary-main);
  background-color: color-mix(in srgb, var(--mui-palette-primary-main) 5%, transparent);
}

.tiptap.ProseMirror .custom-placeholder-node {
  position: relative;
}

.tiptap p.is-editor-empty:first-child::before {
  color: #adb5bd;
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
}


.tiptap.ProseMirror .custom-placeholder-node:not(.is-editor-empty:first-child)::before {
  color: #adb5bd;
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
}

.tiptap.ProseMirror .node-codeBlock.custom-placeholder-node:not(.is-editor-empty:first-child)::before {
  position: absolute;
  height: 1.5rem;
  top: 32px;
  left: 16px;
  z-index: 1;
}

.tiptap.ProseMirror ul[data-type="taskList"].custom-placeholder-node:not(.is-editor-empty:first-child)::before {
  position: absolute;
  height: 1.5rem;
  left: 32px;
  z-index: 1;
}

.tiptap.ProseMirror .custom-horizontal-rule {
  margin: 20px 0;
}

.tiptap.ProseMirror .mark-link a:hover {
  text-decoration: underline;
}

.tiptap.ProseMirror[contenteditable="true"] .node-flipGrid:hover .node-flipGridColumn,
.tiptap.ProseMirror.ProseMirror-focused[contenteditable="true"] .node-flipGrid .node-flipGridColumn {
  background-color: var(--mui-palette-background-paper3);
}

.tiptap.ProseMirror[contenteditable="true"] .node-flipGrid .node-flipGridColumn {
  border-radius: var(--mui-shape-borderRadius);
  padding: 4px;
}

.tiptap.ProseMirror[contenteditable="true"] .node-flipGrid .hover-popover-child,
.tiptap.ProseMirror[contenteditable="true"] .node-flipGrid .flip-grid-column-inner {
  height: 100%;
}

.tiptap.ProseMirror {
  overflow-y: auto;
  outline: none;
  font-size: var(--common-row-font-size);
  color: var(--mui-palette-text-primary);
  line-height: var(--common-row-line-height);
}

/* 节点缩进（依赖 data-indent 属性） */
.tiptap.ProseMirror [data-indent="1"] {
  margin-left: 32px;
}

.tiptap.ProseMirror [data-indent="2"] {
  margin-left: 64px;
}

.tiptap.ProseMirror [data-indent="3"] {
  margin-left: 96px;
}

.tiptap.ProseMirror [data-indent="4"] {
  margin-left: 128px;
}

.tiptap.ProseMirror [data-indent="5"] {
  margin-left: 160px;
}

.tiptap.ProseMirror [data-indent="6"] {
  margin-left: 192px;
}

.tiptap.ProseMirror [data-indent="7"] {
  margin-left: 224px;
}

.tiptap.ProseMirror [data-indent="8"] {
  margin-left: 256px;
}

.tiptap.ProseMirror[contenteditable="false"] {
  padding: 0;
}

.tiptap.ProseMirror :first-child {
  margin-top: 0 !important;
}

.tiptap.ProseMirror :last-child {
  margin-bottom: 0 !important;
}

.tiptap.ProseMirror p {
  margin: 8px 0;
}

.tiptap.ProseMirror blockquote {
  position: relative;
  padding: 8px 16px 8px 24px;
  margin: 8px 0;
  color: var(--mui-palette-text-tertiary);
  background-color: var(--mui-palette-background-paper3);
}

.tiptap.ProseMirror blockquote::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background-color: var(--udtoken-quote-bar-bg);
}

/* list */
.tiptap.ProseMirror ol,
.tiptap.ProseMirror ul {
  padding: 0 32px 0 24px;
  margin: 8px 0;
  list-style: none;
  position: relative;
  counter-reset: list-counter;
}

.tiptap.ProseMirror li {
  display: flex;
  margin: 8px 0;
  flex-direction: column;
  position: relative;
  min-height: var(--common-row-line-height);
}

.tiptap.ProseMirror ol li {
  counter-increment: list-counter;
}

.tiptap.ProseMirror ol li::before {
  position: absolute;
  top: 0;
  left: -24px;
  content: counter(list-counter) '.' !important;
  color: var(--mui-palette-primary-main);
}

.tiptap.ProseMirror ol ol {
  counter-reset: list-counter;
  margin: 0;
}

.tiptap.ProseMirror ol ol li::before {
  content: counter(list-counter, lower-alpha) '.' !important;
}

.tiptap.ProseMirror ol ol ol {
  counter-reset: list-counter;
}

.tiptap.ProseMirror ol ol ol li::before {
  content: counter(list-counter, lower-roman) '.' !important;
}

.tiptap.ProseMirror ol ol ol ol {
  counter-reset: list-counter;
}

.tiptap.ProseMirror ol ol ol ol li::before {
  content: counter(list-counter) '.' !important;
}

.tiptap.ProseMirror ul:not([data-type='taskList']) li::before {
  content: '' !important;
  display: inline-block;
  width: 8px;
  height: 8px !important;
  position: absolute;
  top: 0.5rem;
  left: -24px;
  background: var(--mui-palette-primary-main);
  border-radius: 50%;
  box-sizing: initial;
}

.tiptap.ProseMirror ul:not([data-type='taskList']) ul {
  margin: 0;
}

.tiptap.ProseMirror ul:not([data-type='taskList']) ul li::before {
  width: 5px;
  height: 5px !important;
  background: transparent;
  border: 1.5px solid var(--mui-palette-primary-main);
  border-radius: 50%;
}

.tiptap.ProseMirror ul:not([data-type='taskList']) ul ul li::before {
  width: 4px;
  height: 4px !important;
  background: var(--mui-palette-primary-main);
  border-radius: 0;
}

.tiptap.ProseMirror ul:not([data-type='taskList']) ul ul ul li::before {
  width: 4px;
  height: 4px !important;
  background: transparent;
  border: 1.5px solid var(--mui-palette-primary-main);
  border-radius: 0;
  transform: rotate(45deg);
}

.tiptap.ProseMirror ul[data-type='taskList'] {
  list-style: none;
  margin-left: 0;
  padding: 0;
}

.tiptap.ProseMirror ul[data-type='taskList'] li {
  align-items: flex-start;
  display: flex;
  flex-direction: row;
}

.tiptap.ProseMirror ul[data-type='taskList'] li>label {
  flex-shrink: 0;
  user-select: none;
  margin-right: 8px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tiptap.ProseMirror ul[data-type='taskList'] li>div {
  flex-grow: 1;
}

.tiptap.ProseMirror ul[data-type='taskList'] li[data-checked='true']>div>*:not(ul) {
  color: var(--mui-palette-text-tertiary);
  opacity: 0.7;
  text-decoration: line-through;
}

.tiptap.ProseMirror label:has(input[type="checkbox"]) {
  padding-top: 0;
}

.tiptap.ProseMirror ul[data-type='taskList'] input[type='checkbox'] {
  cursor: pointer;
}

.tiptap.ProseMirror ul[data-type='taskList'] ul[data-type='taskList'] {
  margin: 0;
}

/* details */
.tiptap.ProseMirror .cq-details {
  display: flex;
  gap: 0.25rem;
  margin: 20px 0;
  border: 1px solid var(--mui-palette-divider);
  border-radius: var(--mui-shape-borderRadius);
  padding: 0.5rem;
}

.tiptap.ProseMirror .cq-details summary {
  font-weight: 600;
}

.tiptap.ProseMirror .cq-details>button {
  cursor: pointer;
  background: transparent;
  border-radius: 4px;
  font-size: 0.625rem;
  border: none;
  width: 1.25rem;
  height: 1.5rem;
  margin-top: 0.1rem;
  flex-shrink: 0;
  padding: 0;
}

.tiptap.ProseMirror .cq-details>button:hover {
  background-color: var(--mui-palette-divider);
}

.tiptap.ProseMirror .cq-details>button::before {
  content: '\25B6';
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease-in-out;
}

.tiptap.ProseMirror .cq-details.is-open>button::before {
  transform: rotate(90deg);
}

.tiptap.ProseMirror .cq-details>div {
  width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tiptap.ProseMirror .cq-details>div>[data-type='detailsContent']> :last-child {
  margin-bottom: 0.5rem;
}

.tiptap.ProseMirror .cq-details .cq-details {
  margin: 0.5rem 0;
}

/* emoji */
.tiptap.ProseMirror [data-type='emoji'] img {
  height: 1rem;
  width: 1rem;
  margin: 0;
  padding: 0;
  border: none;
}

/* mention */
.tiptap.ProseMirror .mention {
  background-color: var(--mui-palette-background-paper);
  border-radius: var(--mui-shape-borderRadius);
  box-decoration-break: clone;
  color: var(--mui-palette-primary-main);
  padding: 0.1rem 0.3rem;
}

/* heading */
.tiptap.ProseMirror h1,
.tiptap.ProseMirror h2,
.tiptap.ProseMirror h3,
.tiptap.ProseMirror h4,
.tiptap.ProseMirror h5,
.tiptap.ProseMirror h6 {
  position: relative;
  color: inherit;
  font-style: inherit;
  font-weight: 500;
}

.tiptap.ProseMirror h1 {
  font-size: 26px;
  margin: 26px 0 10px;
}

.tiptap.ProseMirror h2 {
  font-size: 22px;
  margin: 22px 0 8px;
}

.tiptap.ProseMirror h3 {
  font-size: 20px;
  margin: 20px 0 8px;
}

.tiptap.ProseMirror h4 {
  font-size: 18px;
  margin: 18px 0 8px;
}

.tiptap.ProseMirror h5 {
  font-size: 18px;
  margin: 16px 0 8px;
}

.tiptap.ProseMirror h6 {
  font-size: 16px;
  margin: 16px 0 8px;
}

/* horizontal rule */
.tiptap.ProseMirror hr {
  margin: 20px 0;
  border: none;
  height: 1px;
  background-color: var(--mui-palette-divider);
}

.tiptap.ProseMirror table {
  border-collapse: separate;
  border-spacing: 0;
  text-indent: 0;
  max-width: 100%;
  table-layout: fixed;
  overflow: hidden;
  caption-side: top;
  border-left: 1px dotted var(--mui-palette-table-cell-border, --table-cell-border-color);
}

.tiptap.ProseMirror table p {
  font-size: 14px;
}

.tiptap.ProseMirror table th *,
.tiptap.ProseMirror table td * {
  word-break: break-all;
}

.tiptap.ProseMirror table td,
.tiptap.ProseMirror table th {
  border: none;
  border-bottom: 1px solid var(--mui-palette-table-cell-border, --table-cell-border-color);
  border-right: 1px dotted var(--mui-palette-table-cell-border, --table-cell-border-color);
  box-sizing: border-box;
  padding: 12px 16px;
  position: relative;
  vertical-align: top;
  transition: all 0.2s ease-in-out;
  min-width: var(--default-cell-min-width, 100px);
}

.tiptap.ProseMirror table tbody tr:first-child th,
.tiptap.ProseMirror table tbody tr:first-child td {
  border-top: 1px solid var(--mui-palette-table-cell-border, --table-cell-border-color);
}

.tiptap.ProseMirror table td>*,
.tiptap.ProseMirror table th>* {
  margin-bottom: 0 !important;
}

.tiptap.ProseMirror table th {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  background-color: var(--mui-palette-table-head-background, --table-head-background-color);
}

.tiptap.ProseMirror[contenteditable="true"] table .selectedCell * {
  pointer-events: none;
  user-select: none;
}

.tiptap.ProseMirror[contenteditable="true"] table .selectedCell:after {
  background-color: color-mix(in srgb, var(--mui-palette-primary-main) 5%, transparent);
  content: '';
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  pointer-events: none;
  position: absolute;
  z-index: 2;
}

.tiptap.ProseMirror[contenteditable="true"] table .column-resize-handle {
  border-right: 2px dotted var(--mui-palette-primary-main);
  bottom: -2px;
  pointer-events: none;
  position: absolute;
  right: -2px;
  top: 0;
  width: 1px;
  z-index: 3;
  opacity: 0.6;
  transition: all 0.2s ease-in-out;
}

.tiptap-table-dropcursor {
  position: absolute !important;
  z-index: 20;
  pointer-events: none;
  background-color: var(--mui-palette-primary-main, #1976d2);
}

.tiptap.ProseMirror.resize-cursor {
  cursor: col-resize;
}

.tiptap.ProseMirror .tableWrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  position: relative;
}

.tiptap.ProseMirror[contenteditable="true"] .tableWrapper {
  padding-top: 16px;
  padding-left: 16px;
  padding-bottom: 16px;
  padding-right: 16px;
}

.tiptap.ProseMirror .table-controls {
  position: relative;
  overflow: visible;
  pointer-events: none;
}

.tiptap.ProseMirror .table-controls>* {
  pointer-events: auto;
}

.tiptap.ProseMirror .table-selection-overlay-container {
  position: relative;
  overflow: visible;
  pointer-events: none;
}

.tiptap.ProseMirror .table-selection-overlay-container>* {
  pointer-events: auto;
}

.tiptap.ProseMirror .tableWrapper::-webkit-scrollbar {
  height: 5px;
  cursor: pointer;
}

.tiptap.ProseMirror .tableWrapper::-webkit-scrollbar-track {
  background: var(--mui-palette-divider);
  border-radius: 4px;
  cursor: pointer;
}

.tiptap.ProseMirror .tableWrapper::-webkit-scrollbar-thumb {
  background: var(--mui-palette-text-disabled);
  border-radius: 4px;
  cursor: pointer;
}

.tiptap.ProseMirror div[data-youtube-video] {
  cursor: move;
  padding-right: 1.5rem;
}

.tiptap.ProseMirror div[data-youtube-video] iframe {
  border: 1px solid var(--mui-palette-divider);
  padding: 0.25rem;
  border-radius: var(--mui-shape-borderRadius);
  display: block;
  min-height: 200px;
  min-width: 200px;
  outline: 0px solid transparent;
  margin: 20px 0;
}

@keyframes rotate-icon {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.tiptap.ProseMirror .slash-decoration[data-decoration-content].is-empty {
  padding: 4px 8px;
  background-color: var(--mui-palette-background-paper2);
  border-radius: var(--mui-shape-borderRadius);
}

.tiptap.ProseMirror .slash-decoration[data-decoration-content].is-empty::after {
  content: attr(data-decoration-content);
  color: var(--mui-palette-text-disabled);
  padding-left: 0.25rem;
  font-size: 14px;
}

.tiptap.ProseMirror .ai-writing-suggestion {
  color: color-mix(in srgb, var(--mui-palette-text-primary) 15%, transparent);
  pointer-events: none;
  user-select: none;
  white-space: pre-wrap;
}

.tiptap.ProseMirror .cq-details[data-placeholder]::before,
.tiptap.ProseMirror table *[data-placeholder]::before,
.tiptap.ProseMirror li p[data-placeholder]::before {
  display: none;
}

.tiptap.ProseMirror .text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* excalidraw */
body>.excalidraw.excalidraw-modal-container {
  position: fixed;
  z-index: 1400;
  top: auto;
  height: 100vh;
  width: 100vw;
}

.excalidraw button.scroll-back-to-content {
  bottom: 60px;
}