.content-editor {
  --ce-ink: #42334f;
  --ce-muted: #8c7d97;
  --ce-accent: #8964c6;
  --ce-focus: #baa4dc;
  --ce-ease: cubic-bezier(.22, .8, .28, 1);
  box-sizing: border-box;
}
.content-editor *, .content-editor *::before, .content-editor *::after { box-sizing: border-box; }
.ce-mount { display: inline-flex; min-width: 0; }
.cr-edit-tools, .ew-edit-tools { display: flex; justify-content: flex-end; align-items: center; gap: 12px; min-height: 34px; margin: 0 0 12px; }
.reader-edit-tools { display: inline-flex; align-items: center; gap: 12px; margin-left: auto; }
.mm-edit-tools { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.ce-mount .ce-edit-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 34px; padding: 6px 12px; border: 0; border-radius: 9px;
  background: #f0eaf9; color: #8260b4; font: inherit; font-size: 12px; line-height: 1.5; cursor: pointer;
  transition: color 280ms var(--ce-ease), background 280ms var(--ce-ease), transform 280ms var(--ce-ease);
}
.ce-edit-button::before { content: ''; width: 12px; height: 12px; background: currentColor; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m18 2 4 4-14 14-6 2 2-6L18 2zm-2 4 4 4M4 16l4 4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
.ce-mount .ce-edit-button:hover { color: #654296; background: #e8dff6; transform: translateY(-1px); }
.ce-mount .ce-edit-button[aria-expanded="true"] { background: #e8def6; color: #674594; }
/* Editing occupies the same document flow and width as the reading article. */
.ce-reading-hidden { display: none !important; }
.ce-reading-return { animation: ce-reading-return 300ms cubic-bezier(.22, .8, .28, 1) both; }
.ce-panel {
  position: relative; display: block; width: 100%; min-width: 0;
  margin: 0; padding: 0; border: 0; border-radius: 0;
  color: var(--ce-ink); background: transparent; font-family: inherit;
  animation: ce-inline-appear 300ms var(--ce-ease) both;
}
.ce-panel .ce-title { margin: 0; color: #42304e; font-size: 16px; font-weight: 650; line-height: 1.6; overflow: hidden; text-overflow: ellipsis; white-space: normal; overflow-wrap: anywhere; letter-spacing: -.015em; }
.ce-save-actions { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; }
.ce-panel button { font: inherit; font-size: 12px; line-height: 1.5; cursor: pointer; border: 0; transition: background 260ms var(--ce-ease), color 260ms var(--ce-ease), transform 260ms var(--ce-ease), opacity 260ms var(--ce-ease); }
.ce-panel button:active:enabled { transform: scale(.97); }
.ce-panel button:disabled { opacity: .42; cursor: default; }
.ce-panel .ce-quiet { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 5px 10px; border-radius: 7px; background: transparent; color: #8b72a1; }
.ce-panel .ce-quiet:hover:enabled { background: #efe8f7; color: #654693; }
.ce-panel .ce-primary { display: inline-flex; align-items: center; justify-content: center; min-height: 33px; padding: 6px 14px; border-radius: 8px; background: #9470cd; color: #fff; box-shadow: 0 2px 5px #8861bd16; }
.ce-panel .ce-primary:hover:enabled { background: #815bbe; }
.ce-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 18px; }
.ce-mode-tabs { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 9px; background: #efebf3; }
.ce-panel .ce-mode-tab { padding: 6px 12px; border-radius: 6px; color: #95829f; background: transparent; white-space: nowrap; font-size: 11px; }
.ce-panel .ce-mode-tab[aria-selected="true"] { color: #76569b; background: #fff; box-shadow: 0 1px 5px #60417510; }
.ce-edit-pane, .ce-preview { min-height: 360px; min-width: 0; width: 100%; }
.ce-edit-pane { display: block; padding: 0; }
.ce-panel .ce-textarea {
  display: block; width: 100%; min-width: 0; min-height: 360px; resize: none;
  margin: 0; padding: 22px 20px 40px; border: 0; border-radius: 10px; outline: none;
  background: #fcfaff; color: #51425e; caret-color: #9265c9;
  font: 14px/1.95 ui-monospace, 'SFMono-Regular', 'Menlo', 'Consolas', monospace; letter-spacing: .006em;
  tab-size: 2; overflow: hidden; overflow-wrap: anywhere; transition: background 280ms var(--ce-ease);
}
.ce-panel .ce-textarea::selection { background: #e3d3f3; }
.ce-panel .ce-textarea:focus { background: #fbf9ff; }
.ce-textarea:disabled { color: #aaa0b1; }
.ce-preview { padding: 14px 0 36px; background: transparent; }
.ce-panel .ce-preview-article { max-width: 100%; color: #4e415a; font-size: 14px; line-height: 1.95; }
.ce-preview-article :is(h1,h2,h3,h4,h5,h6) { scroll-margin-top: 20px; color: #3b2c47; letter-spacing: -.02em; line-height: 1.55; }
.ce-panel .ce-preview-article h1 { font-size: 27px; margin: 4px 0 24px; }
.ce-panel .ce-preview-article h2 { font-size: 22px; margin: 30px 0 17px; }
.ce-panel .ce-preview-article h3 { font-size: 18px; margin: 26px 0 14px; }
.ce-panel .ce-preview-article h4 { font-size: 15px; margin: 23px 0 12px; }
.ce-panel .ce-preview-article p { margin: 0 0 17px; }
.ce-preview-article img { display: block; width: auto; max-width: 100%; height: auto; max-height: 560px; margin: 18px auto; object-fit: contain; }
.ce-preview-article figure { margin: 22px 0; }
.ce-preview-article figcaption { font-size: 12px; color: #9782a5; line-height: 1.75; margin-top: 10px; }
.ce-preview-article table { display: block; overflow-x: auto; max-width: 100%; width: max-content; border-collapse: collapse; font-size: 12px; line-height: 1.8; margin: 22px 0; }
.ce-preview-article :is(td,th) { padding: 10px 12px; border-bottom: 1px solid #ece4f2; text-align: left; vertical-align: top; }
.ce-preview-article th { background: #f6f1fa; color: #766284; font-weight: 600; }
.ce-preview-article a { color: #8965ba; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ce-preview-article pre { max-width: 100%; overflow: auto; margin: 19px 0; padding: 16px; border-radius: 9px; background: #f7f4fa; font-size: 12px; line-height: 1.7; }
.ce-preview-article blockquote { margin: 22px 0; padding: 4px 0 4px 17px; border-left: 2px solid #d9c7e9; color: #877591; }
.ce-panel .ce-preview-loading { margin: 12px 0; font-size: 13px; color: #9789a2; }
.ce-panel .ce-source-image { display: inline-flex; gap: 8px; padding: 10px 13px; border-radius: 8px; background: #f3eef8; text-decoration: none; font-size: 12px; }
.ce-save-status { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 240px; color: #9b89a5; font-size: 11px; line-height: 1.7; }
.ce-save-status::before { content: ''; flex: 0 0 auto; width: 5px; height: 5px; border-radius: 50%; background: #c6b8d1; transition: background 260ms; }
.ce-save-status[data-state="saved"]::before { background: #8baf94; }
.ce-save-status[data-state="saving"]::before { background: #b196d3; animation: ce-save-pulse 1100ms ease-in-out infinite; }
.ce-save-status[data-state="pending"]::before { background: #c6a575; }
.ce-save-status:is([data-state="error"],[data-state="conflict"]) { color: #b18154; }
.ce-save-status:is([data-state="error"],[data-state="conflict"])::before { background: #c69b72; }
.ce-panel .ce-retry { min-height: 26px; padding-block: 3px; font-size: 11px; }
.ce-conflict { padding: 16px 18px 18px; margin: 0 0 18px; border-radius: 10px; background: #fcf6ef; color: #78634d; }
.ce-panel .ce-conflict h3 { margin: 0 0 6px; font-size: 14px; color: #916d47; line-height: 1.6; }
.ce-panel .ce-conflict-summary { margin: 0 0 12px; font-size: 12px; line-height: 1.7; color: #a18b77; }
.ce-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
.ce-compare-column { min-width: 0; }
.ce-panel .ce-compare h4 { margin: 0 0 6px; font-size: 11px; font-weight: 600; color: #96795f; }
.ce-panel .ce-compare-text { max-height: 150px; min-height: 68px; overflow: auto; margin: 0; padding: 10px; border-radius: 6px; background: #ffffffab; color: #927e6b; font: 11px/1.8 ui-monospace, 'SFMono-Regular', 'Menlo', monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.ce-conflict-actions { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.ce-panel .ce-conflict-actions .ce-primary { background: #b29573; }
.ce-close-question { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; flex: 0 0 auto; padding: 13px 18px; margin-bottom: 16px; border-radius: 10px; background: #f2ecf9; }
.ce-panel .ce-close-question p { flex: 1 1 260px; margin: 0; font-size: 12px; color: #8c779f; line-height: 1.75; }
.ce-panel [hidden] { display: none !important; }
.content-editor :is(button,a,.ce-compare-text):focus-visible { outline: 2px solid var(--ce-focus); outline-offset: 3px; }
.ce-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes ce-inline-appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ce-reading-return { from { opacity: .45; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ce-save-pulse { 0%,100% { opacity: .42; } 50% { opacity: 1; } }
@media (max-width: 760px) {
  .cr-edit-tools, .ew-edit-tools { margin-bottom: 12px; }
  .reader-edit-tools { margin-left: auto; gap: 8px; }
  .mm-edit-tools { margin-top: 10px; }
  .ce-panel { width: 100%; }
  .ce-toolbar { padding: 0 0 12px; gap: 8px; flex-wrap: wrap; }
  .ce-panel .ce-mode-tab { padding: 6px 8px; font-size: 10px; }
  .ce-panel .ce-quiet, .ce-panel .ce-primary { padding-inline: 10px; font-size: 11px; }
  .ce-save-actions { gap: 2px; }
  .ce-panel .ce-textarea { padding: 16px 14px 30px; font-size: 16px; line-height: 1.85; }
  .ce-preview { padding: 12px 0 30px; }
  .ce-save-status { max-width: 125px; font-size: 10px; gap: 5px; }
  .ce-conflict { padding: 14px 12px; }
  .ce-compare { gap: 8px; }
  .ce-panel .ce-compare-text { font-size: 10px; max-height: 120px; }
  .ce-close-question { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .content-editor *, .content-editor *::before, .content-editor *::after, .ce-panel, .ce-reading-return { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
