.yjs-editor-shell {
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
  background: #fff;
  max-width: 820px;
}
.yjs-editor-shell.yjs-full-width { max-width: none; }
.yjs-fullwidth-row { display: flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 2px; color: #444; }

.yjs-status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 12px;
  color: #555;
  background: #f3f3f3;
  border-bottom: 1px solid #ddd;
}
.yjs-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.yjs-status-connected { background: #4caf50; }
.yjs-status-disconnected { background: #e05d44; }

.yjs-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--yjs-tb-gap, 3px);
  padding: 5px;
  background: #fafafa;
  border-bottom: 1px solid #ddd;
}
.yjs-toolbar button {
  border: var(--yjs-tb-border-width, 1px) solid var(--yjs-tb-border, #d5d5d5);
  background: var(--yjs-tb-bg, #ffffff);
  border-radius: 4px;
  padding-top: var(--yjs-tb-padding-y, 3px);
  padding-bottom: var(--yjs-tb-padding-y, 3px);
  padding-left: var(--yjs-tb-padding-x, 7px);
  padding-right: var(--yjs-tb-padding-x, 7px);
  font-size: var(--yjs-tb-font-size, 12.5px);
  line-height: 1.4;
  cursor: pointer;
  min-width: 26px;
  box-sizing: border-box;
  transition: background 0.1s, border-color 0.1s;
}
.yjs-toolbar button:hover { background: var(--yjs-tb-hover-bg, #e8f0fe); border-color: var(--yjs-tb-hover-border, #a8c2f0); }
.yjs-toolbar button:active { background: #d8e6fd; }
.yjs-toolbar-color { width: 26px; height: 24px; padding: 0; border: 1px solid #d5d5d5; border-radius: 4px; cursor: pointer; box-sizing: border-box; }
.yjs-toolbar-select { width: 56px; border: 1px solid #d5d5d5; border-radius: 4px; box-sizing: border-box; background: #fff; cursor: pointer; line-height: 1.4; }
.yjs-toolbar-fontsize-btn { min-width: 44px; }
.yjs-fontsize-popup { padding: 8px; min-width: 140px; }
.yjs-fontsize-stepper { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.yjs-fontsize-dec, .yjs-fontsize-inc { width: 24px; height: 24px; border: 1px solid #ccc; border-radius: 4px; background: #f5f5f5; cursor: pointer; font-size: 14px; line-height: 1; }
.yjs-fontsize-input { flex: 1; width: 0; text-align: center; padding: 3px; border: 1px solid #ccc; border-radius: 4px; font-size: 12.5px; }
.yjs-fontsize-presets { display: flex; flex-direction: column; max-height: 220px; overflow-y: auto; gap: 1px; border-top: 1px solid #eee; padding-top: 4px; }
.yjs-toolbar-dropdown { position: relative; display: inline-block; }
.yjs-toolbar-menu {
  position: fixed; z-index: 200;
  background: #fff; border: 1px solid #ccc; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  min-width: 150px; width: max-content; max-width: 320px; max-height: 70vh; overflow-y: auto;
  padding: 4px; display: flex; flex-direction: column; gap: 1px;
}
.yjs-toolbar-menu-item { text-align: left; border: none; background: none; padding: 5px 8px; border-radius: 4px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.yjs-toolbar-menu-item:hover { background: #e8f0fe; }
.yjs-btn-toggle-active, .yjs-toolbar button.yjs-btn-toggle-active, .yjs-toolbar button.yjs-btn-toggle-active:hover { background: var(--yjs-tb-active-bg, #4075dd); color: var(--yjs-tb-active-text, #fff); border-color: var(--yjs-tb-active-border, #2c5fe0); }
.yjs-editor-content hr { border: none; border-top: 1px solid #c8c8c8; margin: 1em 0; }
.yjs-toolbar-secondary { border-bottom: 1px solid #e5e5e5; opacity: 0.92; }
.yjs-toolbar-sep { width: 1px; background: #ddd; margin: 2px 3px; }

/* Toolbar Customizer panel */
.yjs-tc-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.yjs-tc-panel {
  background: #fff; border-radius: 8px; padding: 20px 24px; width: 640px; max-width: 92vw;
  max-height: 85vh; overflow-y: auto; box-sizing: border-box;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25); font-family: system-ui, sans-serif;
}
@media (min-width: 900px) {
  .yjs-tc-panel { width: 760px; }
  .yjs-tc-list { max-height: 340px; }
  .yjs-tc-avail { max-height: 180px; }
}
.yjs-tc-panel h3 { margin: 0 0 10px; font-size: 15px; }
.yjs-tc-toptabs { margin-bottom: 14px; border-bottom: 1px solid #e2e2e2; padding-bottom: 10px; }
.yjs-tc-body { min-height: 200px; }
.yjs-tc-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.yjs-tc-tab { padding: 5px 12px; border: 1px solid #d5d5d5; border-radius: 4px; background: #f5f5f5; cursor: pointer; font-size: 12.5px; }
.yjs-tc-tab-active { background: #4075dd; color: #fff; border-color: #2c5fe0; }
.yjs-tc-hint { font-size: 11px; color: #888; margin-bottom: 6px; }
.yjs-tc-list { max-height: 220px; overflow-y: auto; border: 1px solid #e2e2e2; border-radius: 6px; padding: 4px 6px; margin-bottom: 8px; }
.yjs-tc-row { display: flex; align-items: center; gap: 4px; padding: 3px 2px; border-bottom: 1px solid #f0f0f0; font-size: 12.5px; }
.yjs-tc-row:last-child { border-bottom: none; }
.yjs-tc-arrow { border: none; background: none; cursor: pointer; font-size: 10px; padding: 2px 4px; }
.yjs-tc-row-label { flex: 1; margin: 0 4px; }
.yjs-tc-row-group { font-size: 10px; color: #999; background: #f0f0f0; padding: 1px 5px; border-radius: 4px; margin-right: 4px; }
.yjs-tc-remove { border: none; background: none; cursor: pointer; color: #c0392b; font-size: 14px; padding: 0 4px; }
.yjs-tc-avail-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #888; margin: 0 0 4px; }
.yjs-tc-avail { max-height: 120px; overflow-y: auto; line-height: 2.2; margin-bottom: 4px; }
.yjs-tc-avail-group { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: #999; margin-right: 4px; }
.yjs-tc-chip { border: 1px solid #d5d5d5; background: #fafafa; border-radius: 4px; padding: 2px 7px; font-size: 11.5px; margin-right: 4px; cursor: pointer; }
.yjs-tc-chip:hover { background: #e8f0fe; }
.yjs-tc-reset, .yjs-tc-cancel, .yjs-tc-save { padding: 6px 12px; border-radius: 4px; border: 1px solid #ccc; background: #f5f5f5; cursor: pointer; font-size: 12.5px; margin-left: 6px; }
.yjs-tc-save, .yjs-tbsettings-actions .yjs-tc-save { background: #4075dd; color: #fff; border-color: #2c5fe0; }

/* Toolbar appearance settings panel */
.yjs-tbsettings-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.yjs-tbsettings-panel {
  background: #fff; border-radius: 8px; padding: 18px 20px; width: 360px; max-width: 90vw;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25); font-family: system-ui, sans-serif;
}
.yjs-tbsettings-panel h3 { margin: 0 0 12px; font-size: 15px; }
.yjs-tbsettings-grid { display: grid; grid-template-columns: 1fr 70px; gap: 8px 10px; align-items: center; }
.yjs-tbsettings-grid label { font-size: 12.5px; color: #444; }
.yjs-tbsettings-grid input[type="color"] { width: 100%; height: 26px; padding: 0; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; }
.yjs-tbsettings-grid input[type="number"] { width: 100%; padding: 4px 6px; border: 1px solid #ccc; border-radius: 4px; }

/* Stacked field layout for the generic field modal (Link/Image/Tag
   Element) — label above a full-width input, unlike the Appearance
   panel's compact 2-column grid (which suits short color/number
   fields, not text). */
.yjs-field-stack { display: flex; flex-direction: column; gap: 10px; min-width: 260px; }
.yjs-field-stack label { font-size: 12px; color: #444; font-weight: 600; }
.yjs-field-item label { display: block; margin-bottom: 3px; }
.yjs-field-row { display: flex; flex-direction: column; gap: 4px; }
.yjs-field-row-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #888; }
.yjs-field-row-items { display: flex; gap: 8px; }
.yjs-field-row-item { flex: 1; min-width: 0; }
.yjs-field-row-item label { display: block; font-size: 10.5px; font-weight: 400; color: #888; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yjs-field-preview-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #888; margin-top: 4px; }
.yjs-field-preview { padding: 16px; background: #f7f7f7; border-radius: 6px; display: flex; align-items: center; justify-content: center; min-height: 50px; }
.yjs-field-stack input[type="text"], .yjs-field-stack input[type="number"], .yjs-field-stack select {
  width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; margin-top: 3px;
}
.yjs-field-stack input[type="color"] { width: 100%; height: 30px; margin-top: 3px; padding: 0; border: 1px solid #ccc; border-radius: 4px; }
.yjs-field-stack textarea { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 12px; font-family: ui-monospace, Menlo, monospace; margin-top: 3px; resize: vertical; }
.yjs-field-checkbox-row { display: flex; align-items: center; gap: 6px; font-weight: 400 !important; }

/* Small popup anchored to its trigger button (Tag Element, matching
   the real editor's own Tag popup style), as opposed to the full
   centered modal used for Link/Image. */
.yjs-field-anchored {
  background: #fff; border: 1px solid #ccc; border-radius: 8px; padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18); z-index: 100; font-family: system-ui, sans-serif;
}
.yjs-field-anchored h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: #667; }
.yjs-tbsettings-actions { display: flex; justify-content: space-between; margin-top: 16px; }
.yjs-tbsettings-actions button { padding: 6px 12px; border-radius: 4px; border: 1px solid #ccc; background: #f5f5f5; cursor: pointer; font-size: 12.5px; }
.yjs-tbsettings-actions .yjs-tbsettings-close { background: #4075dd; color: #fff; border-color: #2c5fe0; }

.yjs-editor-content { padding: 10px 14px; height: 65vh; min-height: 400px; overflow-y: auto; box-sizing: border-box; }
.te-reveal-ids [id] { outline: 1px dashed #f0932b; position: relative; }
.te-reveal-ids [id]::before {
  content: attr(id);
  position: absolute; top: -15px; left: 0;
  font-size: 9px; line-height: 1.4; background: #f0932b; color: #fff;
  padding: 0 4px; border-radius: 2px; white-space: nowrap; z-index: 5; pointer-events: none;
}
.yjs-raw-html { width: 100%; height: 65vh; min-height: 400px; box-sizing: border-box; padding: 10px 14px; border: none; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; resize: vertical; overflow-y: auto; }
.yjs-editor-content .ProseMirror { outline: none; min-height: 220px; }
.yjs-editor-content p { margin: 0 0 0.6em; }
.yjs-editor-content h1, .yjs-editor-content h2, .yjs-editor-content h3 { margin: 0.4em 0; }
.yjs-editor-content blockquote { border-left: 3px solid #ccc; margin: 0.5em 0; padding-left: 10px; color: #555; }
.yjs-editor-content ul, .yjs-editor-content ol { padding-left: 1.4em; }

/* Toggle Box node view */
.pm-toggle-box {
  border: var(--tb-border-width, 1px) solid var(--tb-border-color, #c8c8c8);
  border-radius: var(--tb-radius-tl, 6px) var(--tb-radius-tr, 6px) var(--tb-radius-br, 6px) var(--tb-radius-bl, 6px);
  margin: 0.6em 0;
  overflow: hidden;
}
.pm-toggle-box-header {
  display: flex;
  align-items: center;
  background: var(--tb-header-bg, #2c3a47);
  color: var(--tb-header-text, #fff);
}
.pm-toggle-box-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: inherit;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.pm-toggle-box-toggle::before {
  content: '\25b6';
  font-size: 10px;
  transition: transform 0.15s;
  display: inline-block;
}
.pm-toggle-box-open .pm-toggle-box-toggle::before { transform: rotate(90deg); }
.pm-toggle-box-btn {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.75;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 13px;
}
.pm-toggle-box-btn:hover { opacity: 1; }
.pm-toggle-box-body { padding: var(--tb-padding, 10px); background: var(--tb-body-bg, #fafafa); }
.pm-toggle-box-body > *:last-child { margin-bottom: 0; }

/* Tabs node view */
.pm-tabs {
  border: var(--tabs-border-width, 1px) solid var(--tabs-border-color, #c8c8c8);
  border-radius: var(--tabs-radius-tl, 6px) var(--tabs-radius-tr, 6px) var(--tabs-radius-br, 6px) var(--tabs-radius-bl, 6px);
  margin: 0.6em 0;
  overflow: hidden;
}
.pm-tabs-strip { display: flex; background: var(--tabs-header-bg, #eee); border-bottom: var(--tabs-border-width, 1px) solid var(--tabs-border-color, #c8c8c8); }
.pm-tabs-tab {
  background: none;
  border: none;
  border-right: 1px solid rgba(0,0,0,0.08);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--tabs-header-text, #333);
  cursor: pointer;
}
.pm-tabs-tab-active { background: var(--tabs-active-bg, #fff); color: var(--tabs-active-text, #000); font-weight: 600; }
.pm-tabs-add { margin-left: auto; padding: 6px 10px; border: none; background: none; cursor: pointer; opacity: 0.6; }
.pm-tabs-add:hover { opacity: 1; }
/* 2026-09-18: settings gear, added right after the add-tab button --
   .pm-tabs-add already claims the flex row's leftover space via
   margin-left:auto, so this just sits next to it in normal flow. */
.pm-tabs-settings { padding: 6px 10px; border: none; background: none; cursor: pointer; opacity: 0.6; }
.pm-tabs-settings:hover { opacity: 1; }
.pm-tabs-panels { padding: var(--tabs-padding, 10px); background: var(--tabs-body-bg, #fff); }
/* 2026-09-19: the data-active-index/nth-child mechanism that used to
   live here is gone -- it depended on this.activeIndex, a NodeView-
   local variable the click handler no longer updates (it reads the
   document's own `active` attribute instead now, which survives the
   editor's Yjs sync cycle correctly). Leaving those rules in place
   alongside the newer class-based one below caused BOTH to match --
   the old one still pointing at whatever stale index it was last set
   to, the new one correctly following the real active tab -- so two
   different panes could end up forced visible at once. Only one
   mechanism now: the base hide rule plus the single override below. */
.pm-tab-panel, .wiki-tabs-pane { display: none; }
/* 2026-09-19: this rule's whole point is specificity, not the styles

   themselves -- two classes beats the base .wiki-tabs-pane{display:none}
   rule above regardless of source order, so this can't lose the cascade
   tie the way the data-active-index/nth-child rules further up
   sometimes did. Scoped to THIS stylesheet only (editor-bundle.css,
   loaded only while actively editing) -- the real page's own CSS is
   untouched, so view-mode switching (which only ever toggles this same
   class, never an inline style) keeps working exactly as it always has. */
.wiki-tabs-pane.wiki-tabs-pane-active { display: block; }
.pm-tab-panel > *:last-child, .wiki-tabs-pane > *:last-child { margin-bottom: 0; }

/* Tables (prosemirror-tables) */
.yjs-editor-content table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  margin: 0.6em 0;
  overflow: hidden;
}
.yjs-editor-content td, .yjs-editor-content th {
  border: 1px solid #c8c8c8;
  padding: 6px 8px;
  vertical-align: top;
  position: relative;
}
.yjs-editor-content th { background: #f0f0f0; font-weight: 600; text-align: left; }
.yjs-editor-content .selectedCell { background: rgba(64, 117, 221, 0.15); }
.yjs-editor-content .column-resize-handle {
  position: absolute; right: -2px; top: 0; bottom: 0; width: 4px;
  background: #4075dd; pointer-events: none;
}
.yjs-editor-content.resize-cursor { cursor: col-resize; }

/* Tag Anchor inline badge */
.pm-tag-anchor {
  display: inline-block;
  background: #fef3e6;
  color: #b5680a;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 600;
}

/* y-prosemirror remote cursor/selection rendering */
.ProseMirror-yjs-cursor {
  position: relative;
  margin-left: -1px;
  margin-right: -1px;
  border-left: 1.5px solid black;
  border-right: 1.5px solid black;
  word-break: normal;
  pointer-events: none;
}
.ProseMirror-yjs-cursor > div {
  position: absolute;
  top: -1.05em;
  left: -1px;
  font-size: 11px;
  background: inherit;
  font-family: system-ui, sans-serif;
  font-style: normal;
  font-weight: 600;
  line-height: normal;
  user-select: none;
  color: white;
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
}

/* Shared component controls (2026-09-19): Tabs' component-level move/duplicate/delete buttons sit in the strip
   after the + and settings buttons, styled to match them. */
.pm-tabs-ctl { padding: 6px 8px; border: none; background: none; cursor: pointer; opacity: 0.6; font-size: 12px; color: inherit; }
.pm-tabs-ctl:hover { opacity: 1; }
.pm-tabs-ctl-delete:hover { color: #c0392b; }
/* Info Box move buttons exist only on the editing surface (never in the saved markup); same look as the real
   edit / duplicate / delete buttons defined in the Wiki's style.css. */
.wiki-infobox-up, .wiki-infobox-down {
  width: 30px; height: 30px; border: 1px solid var(--fog-mid, #e2e8ee); background: var(--white, #fff);
  border-radius: 5px; font-size: 13px; line-height: 1; cursor: pointer; color: var(--slate, #2c3a47); touch-action: manipulation;
}
.wiki-infobox-up:hover, .wiki-infobox-down:hover { background: var(--fog, #eff2f5); }
