/* === Sticky ProseMirror menubar inside the editor scroll window (robust) === */
.editor { max-height: 70vh; overflow: auto; position: relative; }
.editor .ProseMirror-menubar-wrapper { position: sticky; top: 0; z-index: 120; background: inherit; }
.editor .ProseMirror-menubar { position: sticky; top: 0; z-index: 120; background: inherit; }
.editor .ProseMirror-menubar {
  padding: 6px 8px;
  border-bottom: 1px solid #d7dde8;
  background: #f8fafc;
}
.editor .ProseMirror-menuitem { margin: 0 6px 6px 0; }
.editor .ProseMirror-menu-active {
  background: #e9f2ff;
  border-radius: 4px;
}

.editor .pm-search-panel {
  display: grid;
  position: sticky;
  top: 0;
  z-index: 119;
  gap: 8px;
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid #d7dde8;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.editor .pm-search-panel[hidden] {
  display: none;
}

.editor .pm-search-row[hidden] {
  display: none;
}

.editor .pm-search-row,
.editor .pm-search-options {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.editor .pm-search-input {
  flex: 1 1 220px;
  min-width: 0;
  border: 1px solid #c3cedd;
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
}

.editor .pm-search-input:focus {
  outline: 2px solid rgba(59, 130, 246, 0.24);
  outline-offset: 1px;
}

.pm-embed-block {
  display: block;
  margin: 0.5rem 0;
}

.pm-embed-inline {
  display: inline-block;
  vertical-align: top;
}

.embed-frame {
  position: relative;
  box-sizing: border-box;
  max-width: 100%;
}

.embed-frame .embed-inner {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
}

.embed-engine-root,
.embed-engine-body {
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
}

.embed-engine-body > * {
  min-width: 0;
  min-height: 0;
}

.pm-embed-block.ProseMirror-selectednode,
.pm-embed-inline.ProseMirror-selectednode {
  outline: none !important;
}

.embed-frame .cm-editor.cm-focused,
.embed-inner .cm-editor.cm-focused {
  outline: none !important;
}

.editor .pm-search-button {
  border: 1px solid #c3cedd;
  border-radius: 6px;
  background: #f8fafc;
  color: #1f2937;
  padding: 7px 10px;
  font: inherit;
  cursor: pointer;
}

.editor .pm-search-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.editor .pm-search-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #475569;
}

.editor .pm-search-status {
  margin-left: auto;
  font-size: 12px;
  color: #475569;
}

.editor .ProseMirror sup { vertical-align: super; font-size: 0.75em; }
.editor .ProseMirror sub { vertical-align: sub; font-size: 0.75em; }

.editor .ProseMirror .pm-scroll-pane {
  border: 1px solid #c8d3e3;
  border-radius: 8px;
  background: #f8fbff;
  margin: 10px 0;
}
.editor .ProseMirror .pm-scroll-pane-title {
  padding: 6px 10px;
  border-bottom: 1px solid #d7e0ec;
  font-size: 12px;
  font-weight: 600;
  color: #3f5169;
}
.editor .ProseMirror .pm-scroll-pane-title:empty {
  display: none;
}
.editor .ProseMirror .pm-scroll-pane-content {
  padding: 10px;
  overflow: auto;
}

.editor .ProseMirror .pm-caption-pane {
  border: 1px solid #c8d3e3;
  border-radius: 8px;
  background: #f8fbff;
  margin: 10px 0;
  display: flex;
  overflow: hidden;
}
.editor .ProseMirror .pm-caption-pane-caption {
  font-size: 12px;
  font-weight: 600;
  color: #3f5169;
  background: #eef4ff;
  border-color: #d7e0ec;
  border-style: solid;
  border-width: 0;
  padding: 8px 10px;
  flex: 0 0 auto;
}
.editor .ProseMirror .pm-caption-pane-caption .ProseMirror {
  min-height: 1.2em;
  outline: none;
}
.editor .ProseMirror .pm-caption-pane-content {
  padding: 10px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.editor .ProseMirror .pm-caption-pane-content .ProseMirror {
  min-height: 2.4em;
  outline: none;
}
.editor .ProseMirror .pm-caption-side-top,
.editor .ProseMirror .pm-caption-side-bottom {
  flex-direction: column;
}
.editor .ProseMirror .pm-caption-side-top .pm-caption-pane-caption {
  border-bottom-width: 1px;
}
.editor .ProseMirror .pm-caption-side-bottom .pm-caption-pane-caption {
  order: 2;
  border-top-width: 1px;
}
.editor .ProseMirror .pm-caption-side-left,
.editor .ProseMirror .pm-caption-side-right {
  flex-direction: row;
}
.editor .ProseMirror .pm-caption-side-left .pm-caption-pane-caption {
  border-right-width: 1px;
}
.editor .ProseMirror .pm-caption-side-right .pm-caption-pane-caption {
  order: 2;
  border-left-width: 1px;
}

.pm-dock-frame {
  border: 1px solid #b6c4d8;
  border-radius: 8px;
  background: #f6f9ff;
  box-sizing: border-box;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}
.pm-dock-frame-title {
  padding: 6px 10px;
  border-bottom: 1px solid #d7e0ec;
  font-size: 12px;
  font-weight: 600;
  color: #3f5169;
}
.pm-dock-frame-content {
  padding: 10px;
  box-sizing: border-box;
  white-space: pre-wrap;
}

.pm-dock-frame-anchor {
  display: block !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: visible !important;
  line-height: 0 !important;
}

/* === Edit Inline Object dialog: WHITE theme for readability === */
.embed-attrs-dialog { background: #fff; color: #222; border-radius: 8px; padding: 16px; }
.embed-attrs-head, .embed-attrs-foot { background: #f2f2f2; color: #222; padding: 8px 12px; border-radius: 6px; }
.embed-attrs-body { background: #fff; color: #111; padding: 12px; border-radius: 6px; }
.embed-attrs-body input, .embed-attrs-body select, .embed-attrs-body textarea {
  background: #fff; color: #111; border: 1px solid #bbb; border-radius: 4px; padding: 6px 8px;
}

/* Keep code/pyodide readable on white */
.embed-attrs-body pre { background: #fafafa; border: 1px solid #e0e0e0; border-radius: 4px; padding: 8px; overflow-x: auto; }
.embed-attrs-body code { color: #222; }

/* ProseMirror table defaults: make cell boundaries clearly visible */
.editor .ProseMirror table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
}

.editor .ProseMirror th,
.editor .ProseMirror td {
  border: 1px solid #9aa4b2;
  padding: 6px 8px;
  vertical-align: top;
}

.editor .ProseMirror th {
  background: #f3f6fa;
}

.editor .ProseMirror .remote-caret .remote-caret-bar {
  animation: pm-remote-caret-blink 1s step-end infinite;
}

.editor .ProseMirror .remote-selection {
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  opacity: 1;
}

@keyframes pm-remote-caret-blink {
  0%, 45% { opacity: 1; }
  50%, 95% { opacity: 0; }
  100% { opacity: 1; }
}
