:root {
  --bg-0: #0b1020;
  --bg-1: #0e1530;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-2: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.68);
  --muted-2: rgba(255, 255, 255, 0.54);
  --accent: #7c5cff;
  --accent-2: #39d0ff;
  --danger: #ff3b6a;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.28);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;
  --focus: 0 0 0 3px rgba(124, 92, 255, 0.28);
  --doc-bg: rgba(255, 255, 255, 0.06);
  --doc-border: rgba(255, 255, 255, 0.12);
  --paper-bg: rgba(255, 255, 255, 0.10);
  --paper-shadow: 0 25px 70px rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] {
  --bg-0: #f6f7fb;
  --bg-1: #eef2ff;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-2: rgba(255, 255, 255, 0.70);
  --panel-border: rgba(8, 12, 26, 0.10);
  --text: rgba(10, 14, 24, 0.92);
  --muted: rgba(10, 14, 24, 0.66);
  --muted-2: rgba(10, 14, 24, 0.52);
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.14);
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.12);
  --doc-bg: rgba(255, 255, 255, 0.88);
  --doc-border: rgba(8, 12, 26, 0.08);
  --paper-bg: #ffffff;
  --paper-shadow: 0 25px 70px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background-color: var(--bg-0);
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 15% 10%, rgba(124, 92, 255, 0.22), transparent 55%),
    radial-gradient(900px 600px at 75% 0%, rgba(57, 208, 255, 0.18), transparent 60%),
    radial-gradient(900px 700px at 60% 85%, rgba(255, 59, 106, 0.14), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
}

.app {
  min-height: 100%;
}

.topbar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1280px, calc(100% - 28px));
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 50;
}

.topbar__row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
}

.topbar__row--primary {
  padding-bottom: 10px;
}

.topbar__row--secondary {
  padding-top: 0;
  padding-bottom: 12px;
  align-items: flex-start;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
}

.brand__name {
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  position: relative;
  cursor: help;
}

/* Tooltip styles */
.brand__name::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 12px;
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.95);
  color: white;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(5px) scale(0.95);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  z-index: 100;
  backdrop-filter: blur(4px);
}

.brand__name::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 20px;
  margin-top: 6px;
  border: 6px solid transparent;
  border-bottom-color: rgba(15, 23, 42, 0.95);
  opacity: 0;
  transform: translateY(5px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  z-index: 101;
}

.brand__name:hover::after {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.brand__name:hover::before {
  opacity: 1;
  transform: translateY(0);
}

.brand__titleInput {
  flex: 1;
  min-width: 160px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  outline: none;
}

.brand__titleInput:focus {
  box-shadow: var(--focus);
}

.appActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sep {
  width: 1px;
  height: 22px;
  background: var(--panel-border);
  margin: 0 4px;
}

.btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  background: transparent;
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 -1px 2px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  transition: all 150ms linear 0s;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25),
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 0 0 rgba(0, 0, 0, 0.5) inset,
    0 1.10em 0 rgba(255, 255, 255, 0.25) inset,
    0 -1.10em 1.25em rgba(0, 0, 0, 0.32) inset,
    0 1.10rem 1.25em rgba(255, 255, 255, 0.05) inset,
    0 1.10em 6px rgba(255, 255, 255, 0.10) inset;
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(100% 100% at 50% 15%, rgba(152, 46, 82, 1) 15%, rgba(31, 37, 95, 1) 55%, rgba(12, 22, 47, 1) 100%);
}

.btn:hover {
  border-color: rgba(0, 0, 0, 0.55);
  box-shadow:
    0 5px 6px rgba(0, 0, 0, 0.16),
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 0 0 rgba(0, 0, 0, 0.25) inset,
    0 20px 0 rgba(255, 255, 255, 0.04) inset,
    0 -20px 20px rgba(0, 0, 0, 0.32) inset,
    0 20px 20px rgba(255, 255, 255, 0.07) inset;
  filter: saturate(110%) brightness(1.08);
}

.btn:active {
  transform: translateY(1px);
  box-shadow:
    1px 1px 1px rgba(255, 255, 255, 0.85),
    0 1px 0 rgba(255, 255, 255, 0.25),
    0 1px 0 rgba(255, 255, 255, 0) inset,
    0 0 5px rgba(0, 0, 0, 0.40) inset,
    0 20px 0 rgba(255, 255, 255, 0.03) inset,
    0 -20px 20px rgba(0, 0, 0, 0.25) inset,
    0 20px 20px rgba(255, 255, 255, 0.05) inset;
  filter: saturate(120%);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus),
    0 5px 6px rgba(0, 0, 0, 0.16),
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 0 0 rgba(0, 0, 0, 0.25) inset,
    0 20px 0 rgba(255, 255, 255, 0.04) inset,
    0 -20px 20px rgba(0, 0, 0, 0.32) inset,
    0 20px 20px rgba(255, 255, 255, 0.07) inset;
}

.btn--primary {
  filter: saturate(125%) brightness(1.05);
}

.btn--primary:hover {
  filter: saturate(135%) brightness(1.10);
}

.iconBtn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  background: transparent;
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 -1px 2px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  font-size: 20px;
  line-height: 0;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  transition: all 150ms linear 0s;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25),
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 0 0 rgba(0, 0, 0, 0.5) inset,
    0 1.10em 0 rgba(255, 255, 255, 0.25) inset,
    0 -1.10em 1.25em rgba(0, 0, 0, 0.32) inset,
    0 1.10rem 1.25em rgba(255, 255, 255, 0.05) inset,
    0 1.10em 6px rgba(255, 255, 255, 0.10) inset;
}

.iconBtn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(100% 100% at 50% 15%, rgba(152, 46, 82, 1) 15%, rgba(31, 37, 95, 1) 55%, rgba(12, 22, 47, 1) 100%);
}

.iconBtn:hover {
  border-color: rgba(0, 0, 0, 0.55);
  filter: saturate(110%) brightness(1.08);
}

.iconBtn:active {
  transform: translateY(1px);
  filter: saturate(120%);
}

.iconBtn:focus-visible {
  outline: none;
  box-shadow: var(--focus), 0 5px 6px rgba(0, 0, 0, 0.16);
}

.btn .shine,
.iconBtn .shine {
  content: "";
  width: 200%;
  height: 200%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: inherit;
  background:
    linear-gradient(-115deg, transparent 20%, rgba(183, 183, 183, 0.25) 26%, transparent 32%),
    linear-gradient(-115deg, transparent 20%, rgba(255, 255, 255, 0.18) 35%, transparent 48%);
  background-size: 400% 800%, 400% 1200%;
  filter: blur(10px);
  transition: all 150ms ease-in-out 0s;
  background-blend-mode: color-burn, overlay;
  mix-blend-mode: color-dodge;
  z-index: 0;
  animation: buttonGradientMove 13s infinite;
  animation-play-state: running;
  opacity: 1;
  pointer-events: none;
}

.btn:hover .shine,
.btn:active .shine,
.iconBtn:hover .shine,
.iconBtn:active .shine {
  animation-play-state: paused;
  opacity: 0;
}

@keyframes buttonGradientMove {
  50% {
    background-position: 100% 0, 100% 0;
  }
}

.editorToolbar {
  flex: 1;
  min-width: 280px;
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  /* overflow: hidden; Removed to allow sticky/fixed tooltips to show */
  overflow: visible !important;
}

.topbarMeta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 110px;
  justify-content: flex-end;
}

.saveState {
  font-weight: 700;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
}

.saveState.isDirty {
  color: var(--danger);
  border-color: rgba(255, 59, 106, 0.32);
}

.saveState.isSaving {
  color: var(--accent-2);
  border-color: rgba(57, 208, 255, 0.28);
}

.main {
  padding-top: calc(var(--topbar-height, 132px) + 22px);
  padding-bottom: calc(72px + 22px);
  display: flex;
  justify-content: center;
}

.editorSurface {
  width: min(1200px, calc(100% - 28px));
}

.editorSurface.isDragOver .doc {
  border-color: rgba(57, 208, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(57, 208, 255, 0.18), var(--shadow-soft);
}

.doc {
  min-height: calc(100vh - var(--topbar-height, 132px) - 130px);
  padding: 30px;
  border-radius: var(--radius-lg);
  background: var(--doc-bg);
  border: 1px solid var(--doc-border);
  box-shadow: var(--shadow-soft);
  outline: none;
  line-height: 1.65;
  font-size: 16px;
  letter-spacing: 0.15px;
}

body.isPageMode .editorSurface {
  width: min(980px, calc(100% - 28px));
}

body.isPageMode .doc {
  background: var(--paper-bg);
  box-shadow: var(--paper-shadow);
}

.doc h1 {
  font-size: 2.1rem;
  margin: 0.9rem 0 0.5rem;
}

.doc h2 {
  font-size: 1.7rem;
  margin: 0.9rem 0 0.4rem;
}

.doc h3 {
  font-size: 1.35rem;
  margin: 0.9rem 0 0.4rem;
}

.doc p {
  margin: 0.65rem 0;
}

.doc blockquote {
  margin: 0.9rem 0;
  padding: 0.7rem 0.9rem;
  border-left: 4px solid rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.10);
  border-radius: 12px;
}

.doc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.doc pre {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.22);
  overflow: auto;
}

html[data-theme="light"] .doc pre {
  background: rgba(2, 6, 23, 0.06);
}

.doc img {
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

html[data-theme="light"] .doc img {
  border-color: rgba(2, 6, 23, 0.10);
}

.statusbar {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1280px, calc(100% - 28px));
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 700;
  z-index: 45;
}

.visuallyHidden {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  white-space: nowrap;
  clip-path: inset(100%);
  clip: rect(0 0 0 0);
  overflow: hidden;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.overlay.isHidden {
  display: none;
}

.modal {
  width: min(760px, calc(100% - 30px));
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}

.modal__title {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
}

.modal__body {
  padding: 14px 16px 16px;
}

.mdInput {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  outline: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1.45;
}

html[data-theme="light"] .mdInput {
  background: rgba(2, 6, 23, 0.05);
}

.mdInput:focus {
  box-shadow: var(--focus);
}

.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
  flex-wrap: wrap;
}

.exportGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width:700px) {
  .exportGrid {
    grid-template-columns: 1fr;
  }
}

.exportCard {
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
}

.exportCard__title {
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text);
}

.exportCard__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actionSelect {
  height: 36px;
  padding: 0 44px 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  background: radial-gradient(100% 100% at 50% 15%, rgba(152, 46, 82, 1) 15%, rgba(31, 37, 95, 1) 55%, rgba(12, 22, 47, 1) 100%);
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 -1px 2px rgba(0, 0, 0, 0.2);
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25),
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 0 0 rgba(0, 0, 0, 0.5) inset,
    0 1.10em 0 rgba(255, 255, 255, 0.25) inset,
    0 -1.10em 1.25em rgba(0, 0, 0, 0.32) inset,
    0 1.10rem 1.25em rgba(255, 255, 255, 0.05) inset,
    0 1.10em 6px rgba(255, 255, 255, 0.10) inset;
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px 14px;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20'%3E%3Cpath fill='rgba(255,255,255,0.92)' d='M5.5 7.5 10 12l4.5-4.5 1.4 1.4-5.9 5.9-5.9-5.9z'/%3E%3C/svg%3E");
}

.actionSelect option {
  color: var(--text);
  background-color: var(--bg-0);
}

.actionSelect:hover {
  filter: saturate(110%) brightness(1.08);
  border-color: rgba(0, 0, 0, 0.55);
}

.actionSelect:focus-visible {
  box-shadow: var(--focus), 0 5px 6px rgba(0, 0, 0, 0.16);
}

.actionSelect:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: none;
}

.exportHint {
  margin-top: 12px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.4;
}

.toastStack {
  position: fixed;
  top: calc(var(--topbar-height, 132px) + 22px);
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 300;
}

.toast {
  width: min(360px, calc(100vw - 36px));
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-soft);
  padding: 10px 12px;
  color: var(--text);
  font-weight: 700;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.toast__msg {
  flex: 1;
  color: var(--text);
}

.toast__close {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.toast__close:hover {
  background: rgba(255, 255, 255, 0.08);
}

#editorToolbar .tox {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

#editorToolbar .tox .tox-toolbar,
#editorToolbar .tox .tox-toolbar__primary,
#editorToolbar .tox .tox-toolbar__overflow,
#editorToolbar .tox .tox-toolbar__group {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

#editorToolbar .tox .tox-tbtn {
  border-radius: 12px !important;
}

#editorToolbar .tox .tox-tbtn:hover {
  background: rgba(255, 255, 255, 0.09) !important;
}

#editorToolbar .tox .tox-tbtn--enabled {
  background: rgba(124, 92, 255, 0.26) !important;
}

#editorToolbar .tox .tox-tbtn:focus-visible {
  box-shadow: var(--focus) !important;
}

#editorToolbar .tox .tox-tbtn svg {
  fill: currentColor !important;
}

#editorToolbar .tox .tox-split-button:hover {
  background: rgba(255, 255, 255, 0.09) !important;
}

#editorToolbar .tox .tox-edit-area__iframe {
  background: transparent !important;
}

#editorToolbar .tox .tox-toolbar__group:not(:last-child) {
  border-right: 1px solid rgba(255, 255, 255, 0.10) !important;
}

html[data-theme="light"] #editorToolbar .tox .tox-toolbar__group:not(:last-child) {
  border-right: 1px solid rgba(2, 6, 23, 0.10) !important;
}

#editorToolbar .tox .tox-toolbar-overlord {
  padding: 4px 6px;
}

/* UI Container: Cover viewport but allow click-through */
.tox-tinymce-aux {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 2147483647 !important;
  pointer-events: none;
}

/* Dialogs: Force Center Screen */
/* Dialogs: Force Center Screen */
.tox-dialog-wrap {
  position: fixed !important;
  inset: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  pointer-events: auto;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 2147483647 !important;
}

.tox-dialog-wrap__backdrop {
  background-color: rgba(0, 0, 0, 0.4) !important;
  backdrop-filter: blur(8px) !important;
  /* Premium blur effect */
}

/* Menus: Enable clicks */
.tox-menu,
.tox-pop,
.tox-autocompleter,
.tox-dialog {
  pointer-events: auto;
  z-index: 2147483647 !important;
}

/* Dialog: Premium Styling */
/* Dialog: Premium Styling */
.tox-dialog {
  position: relative !important;
  margin: auto !important;
  max-width: 95vw !important;
  max-height: 95vh !important;
  width: 700px !important;
  /* Larger default width */
  min-height: 400px !important;

  /* Dark Theme Overrides */
  border-radius: 16px !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6) !important;
  background-color: #1e1e2f !important;
  /* Match app dark theme */
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
  overflow: hidden !important;
  /* Hide ugly outer wrapper scrollbars */
  display: flex !important;
  flex-direction: column !important;
}

.tox-dialog__body {
  flex: 1;
  overflow: auto;
  /* Internal scrolling if absolutely needed */
}

/* Remove scrollbar track if not needed */
.tox-dialog__body::-webkit-scrollbar {
  width: 8px;
  background: transparent;
}

.tox-dialog__body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* Header & Footer styling for dark mode consistency */
.tox-dialog__header,
.tox-dialog__footer {
  background-color: transparent !important;
  color: #e2e8f0 !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

.tox-dialog__title {
  color: #fff !important;
  font-family: 'Outfit', sans-serif !important;
}

.tox-button {
  border-radius: 8px !important;
}

/* Inner inputs and labels */
.tox-label,
.tox-form__group-label {
  color: #94a3b8 !important;
}

.tox-textfield,
.tox-listbox,
.tox-textarea,
.tox-textarea-wrap .tox-textarea {
  background-color: rgba(0, 0, 0, 0.2) !important;
  color: #f1f5f9 !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  border-radius: 6px !important;
}

.tox-textfield:focus,
.tox-listbox:focus,
.tox-textarea:focus {
  background-color: rgba(0, 0, 0, 0.3) !important;
  border-color: #8b5cf6 !important;
  /* Primary purple */
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3) !important;
}

/* Dropzone (Image Upload) */
.tox-dropzone {
  background-color: rgba(0, 0, 0, 0.2) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #cbd5e1 !important;
}

.tox-dropzone .tox-dropzone__text {
  color: #94a3b8 !important;
}

/* Tabs */
.tox-dialog__body-nav {
  background-color: transparent !important;
}

.tox-dialog__body-nav-item {
  color: #94a3b8 !important;
}

.tox-dialog__body-nav-item--active {
  color: #8b5cf6 !important;
  /* Primary purple */
  border-bottom-color: #8b5cf6 !important;
}

/* Menus & Dropdowns: Dark Theme */
.tox-menu,
.tox-collection,
.tox-collection__group,
.tox-selected-menu {
  background-color: #1e1e2f !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Fix Text Contrast in Lists (e.g., Help Dialog & Dropdowns) */
.tox-collection__item,
.tox-collection__item-label,
.tox-collection__item-accessory,
.tox-dialog__body-content,
.tox-dialog__body-content * {
  color: #e2e8f0 !important;
  background-color: transparent !important;
}

.tox-collection__item:hover,
.tox-collection__item--active {
  background-color: rgba(139, 92, 246, 0.2) !important;
  /* Purple hover */
  color: #fff !important;
}

/* Scrollbar for menus */
.tox-menu__content::-webkit-scrollbar {
  width: 6px;
  background: transparent;
}

.tox-menu__content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* Ensure links are distinct */
.tox-dialog__body-content a {
  color: #8b5cf6 !important;
}

/* Ensure dialog itself is centered and not absolutely positioned by JS overrides if possible */
.tox-dialog {
  position: relative !important;
  margin: auto !important;
  max-height: 95vh !important;
  max-width: 95vw !important;
}

/* Ensure the toolbar allows overflow */
#editorToolbar,
#editorToolbar .tox,
#editorToolbar .tox-toolbar-overlord {
  overflow: visible !important;
}