/* styles-editor.css — extracted from styles.css (Editor, inline link preview, version history styles) */

/* ── Editor (editor.js) ──────────────────────────────────────── */

      .preview-area table {
        width: 100%;
        border-collapse: collapse;
        margin: 12px 0;
        font-size: var(--fs-base);
      }
      .preview-area th {
        background: rgba(var(--primary-rgb), 0.15);
        color: var(--primary);
        padding: 8px 12px;
        text-align: left;
        border: 1px solid var(--glass-border);
        font-weight: 600;
      }
      .preview-area td {
        padding: 8px 12px;
        border: 1px solid var(--glass-border);
      }
      .preview-area tr:nth-child(even) {
        background: rgba(255, 255, 255, 0.02);
      }
      .preview-area tr:hover {
        background: rgba(var(--primary-rgb), 0.06);
      }
      .preview-area pre {
        background: rgba(13, 17, 23, 0.9);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-base);
        padding: 14px;
        margin: 10px 0;
        overflow-x: auto;
        position: relative;
      }
      .code-copy-btn {
        position: absolute;
        top: 4px;
        right: 4px;
        background: rgba(255, 255, 255, 0.1);
        border: none;
        cursor: pointer;
        border-radius: var(--radius-xs);
        padding: 2px 6px;
        opacity: 0.5;
        transition: opacity 0.2s;
        font-size: var(--fs-base);
        line-height: 1;
        z-index: var(--z-base);
      }
      .code-copy-btn:hover {
        opacity: 1;
        background: rgba(255, 255, 255, 0.2);
      }
      .preview-area pre code {
        font-family: var(--font-mono);
        font-size: var(--fs-base);
        line-height: 1.5;
      }
      .preview-area code {
        font-family: var(--font-mono);
        font-size: var(--fs-base);
        background: rgba(var(--primary-rgb), 0.1);
        padding: 2px 6px;
        border-radius: var(--radius-xs);
      }
      .preview-area pre code {
        background: none;
        padding: 0;
      }
      .preview-area .katex-display {
        margin: 12px 0;
        overflow-x: auto;
      }
      .preview-area .katex {
        color: var(--text-main);
      }
      .wiki-preview-popup {
        position: fixed;
        z-index: var(--z-modal);
        background: var(--card-bg-solid);
        border: 1px solid rgba(var(--primary-rgb), 0.35);
        border-radius: var(--radius-md);
        padding: 12px 14px;
        max-width: 280px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
        pointer-events: auto;
        animation: gn-popup-in 0.15s ease;
      }
      .wiki-preview-popup .wp-title {
        font-size: var(--fs-base);
        font-weight: 700;
        color: var(--primary-light);
        margin-bottom: 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .wiki-preview-popup .wp-tags {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        margin-bottom: 6px;
      }
      .wiki-preview-popup .wp-tag {
        font-size: var(--fs-xs);
        color: var(--secondary);
        background: rgba(var(--secondary-rgb, 99,102,241), 0.12);
        padding: 1px 6px;
        border-radius: var(--radius-sm, 4px);
        white-space: nowrap;
      }
      .wiki-preview-popup .wp-body {
        font-size: var(--fs-sm);
        color: var(--text-dim);
        line-height: 1.5;
      }
      .wiki-preview-popup .wp-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 8px;
        gap: 8px;
      }
      .wiki-preview-popup .wp-date {
        font-size: var(--fs-xs);
        color: var(--text-dim);
        opacity: 0.7;
      }
      .wiki-preview-popup .wp-hint {
        font-size: var(--fs-xs);
        color: rgba(var(--primary-rgb), 0.5);
        margin-left: auto;
      }
body.light-mode .wiki-preview-popup {
  background: var(--card-bg-solid);
  border-color: rgba(0,0,0,0.12);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
body.light-mode .wiki-preview-popup .wp-tag {
  background: rgba(99,102,241,0.08);
}
.wiki-preview-empty {
  opacity: 0.4;
  font-style: italic;
}

/* ── Inline Link Preview Tooltip (external URLs) ──────────── */
.link-preview-tooltip {
  position: fixed;
  z-index: var(--z-modal);
  background: var(--card-bg-solid);
  border: 1px solid rgba(var(--primary-rgb), 0.25);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  max-width: 280px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  animation: gn-popup-in 0.12s ease;
}
.link-preview-tooltip .lpt-domain {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--primary-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-preview-tooltip .lpt-favicon {
  flex-shrink: 0;
  border-radius: var(--radius-xs);
}
.link-preview-tooltip .lpt-url {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  margin-top: 4px;
  word-break: break-all;
  line-height: 1.4;
  opacity: 0.8;
}
.link-preview-tooltip .lpt-hint {
  font-size: var(--fs-xs);
  color: rgba(var(--primary-rgb), 0.5);
  margin-top: 6px;
  text-align: right;
}
body.light-mode .link-preview-tooltip {
  background: var(--card-bg-solid);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}

.at-item { display: flex; align-items: center; gap: 8px; }
.at-item--selected { background: rgba(var(--primary-rgb), 0.15); }
.at-label-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.at-label { font-size: var(--fs-base); color: var(--text-main); min-width: 0; flex: 1; }
.at-badge { border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-lg); padding: 2px 6px; flex-shrink: 0; }
body.light-mode .at-badge { border-color: rgba(0,0,0,0.12); }
.at-search-wrap { padding: 6px 8px 4px; }

/* ── Format Remove BG Button ── */
      .fmt-remove-bg-btn {
        display: flex;
        align-items: center;
        gap: 6px;
        width: 100%;
        background: none;
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: var(--radius-sm);
        color: var(--text-dim);
        padding: 4px 8px;
        cursor: pointer;
        font-size: var(--fs-base);
        margin-bottom: 6px;
      }
      .fmt-remove-bg-btn:hover,
      .fmt-remove-bg-btn:focus-visible {
        border-color: rgba(255, 255, 255, 0.4);
      }
      body.light-mode .fmt-remove-bg-btn {
        border-color: rgba(0, 0, 0, 0.12);
        color: var(--text-muted);
      }
      body.light-mode .fmt-remove-bg-btn:hover,
      body.light-mode .fmt-remove-bg-btn:focus-visible {
        border-color: rgba(0, 0, 0, 0.3);
      }
      .fmt-remove-bg-icon {
        width: 16px;
        height: 16px;
        border: 1.5px solid var(--text-secondary, #888);
        border-radius: var(--radius-xs);
        background: transparent;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: var(--fs-xs);
        color: var(--color-danger, #f44);
      }

/* ── Editor Layout + Toolbar ── */
      .editor-col {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
      .editor-space {
        flex: 1;
        padding: 0.5rem 1.5rem 1.5rem 1.5rem;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
        position: relative;
      }
      .editor-toolbar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 0.5rem;
        gap: 4px;
      }
      .editor-title-row {
        display: flex;
        align-items: center;
        gap: 6px;
        position: relative;
      }
      .editor-meta-row {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
      }
      .editor-title {
        background: transparent;
        border: none;
        color: var(--text-dim);
        font-size: var(--fs-2xl);
        font-weight: 700;
        flex: 1;
        font-family: inherit;
      }
      .editor-title:focus:not(:focus-visible) { outline: none; }
      .editor-title::placeholder {
        color: rgba(255, 255, 255, 0.2);
      }
      .toolbar-actions {
        display: flex;
        gap: 3px;
        align-items: center;
        flex-wrap: nowrap;
        justify-content: flex-end;
        flex-shrink: 1;
        overflow-x: auto;
        overflow-y: hidden;
        min-width: 0;
      }
      .toolbar-actions::-webkit-scrollbar {
        height: 0;
      }
      /* Reorder mode: subtle outline on draggable containers */
      .reorder-active {
        outline: 1px dashed rgba(var(--primary-rgb), 0.35);
        outline-offset: 2px;
        border-radius: var(--radius-base);
      }
      .reorder-active .tool-btn,
      .reorder-active .fmt-btn,
      .reorder-active .hdr-btn {
        transition: opacity 0.15s, transform 0.15s;
      }
      .reorder-active .tool-btn:hover,
      .reorder-active .fmt-btn:hover,
      .reorder-active .hdr-btn:hover {
        outline: 1px solid rgba(var(--primary-rgb), 0.4);
        outline-offset: 1px;
      }
      .word-count {
        font-size: var(--fs-sm);
        color: var(--text-dim);
        font-family: var(--font-mono);
        white-space: nowrap;
      }
      .tool-btn {
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid var(--glass-border);
        color: var(--text-dim);
        padding: 4px 6px;
        border-radius: var(--radius-base);
        cursor: pointer;
        font-size: var(--fs-sm);
        transition: 0.2s;
        white-space: nowrap;
        line-height: 1;
      }
      .tool-btn:hover {
        background: rgba(255, 255, 255, 0.08);
        color: var(--text-main);
        border-color: rgba(255, 255, 255, 0.2);
      }
      .tool-btn-green {
        background: rgba(var(--color-success-rgb), 0.1);
        border-color: var(--color-success);
        color: var(--color-success);
      }
      .tool-btn-green:hover {
        background: rgba(var(--color-success-rgb), 0.2);
        color: var(--color-success);
      }
      /* Formatting Toolbar */
      .format-toolbar {
        display: flex;
        align-items: center;
        gap: 2px;
        padding: 3px 6px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: var(--radius-base);
        margin-bottom: 6px;
        flex-wrap: wrap;
        overflow: visible;
        transition: all 0.2s;
        flex-shrink: 0;
      }
      .format-toolbar::-webkit-scrollbar {
        height: 0;
      }
      .format-toolbar:hover {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(var(--primary-rgb), 0.2);
      }
      .fmt-group {
        display: flex;
        align-items: center;
        gap: 1px;
        flex-shrink: 0;
      }
      .fmt-separator {
        width: 1px;
        height: 16px;
        background: rgba(255, 255, 255, 0.08);
        margin: 0 2px;
        flex-shrink: 0;
      }
      .fmt-btn {
        background: transparent;
        border: 1px solid transparent;
        color: rgba(255, 255, 255, 0.6);
        padding: 3px 5px;
        border-radius: var(--radius-sm);
        cursor: pointer;
        font-size: var(--fs-sm);
        transition: all 0.15s;
        min-width: 22px;
        text-align: center;
        line-height: 1;
      }

      .fmt-btn:hover {
        background: rgba(var(--primary-rgb), 0.15);
        color: var(--primary);
        border-color: rgba(var(--primary-rgb), 0.3);
      }
      .fmt-btn:active {
        transform: scale(0.93);
      }
      .fmt-select {
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.7);
        padding: 2px 4px;
        border-radius: var(--radius-sm);
        font-size: var(--fs-sm);
        cursor: pointer;
        outline: none;
        font-family: inherit;
        min-width: 50px;
      }
      .fmt-select:hover {
        border-color: rgba(var(--primary-rgb), 0.4);
      }
      .fmt-select option {
        background: var(--card-bg-solid);
        color: var(--text-main);
      }
      .fmt-color-dropdown {
        position: relative;
      }
      .fmt-color-trigger {
        background: transparent;
        border: 1px solid transparent;
        color: rgba(255, 255, 255, 0.6);
        padding: 4px 8px;
        border-radius: var(--radius-sm);
        cursor: pointer;
        font-size: var(--fs-md);
        font-weight: 700;
        transition: all 0.15s;
        min-width: 28px;
        text-align: center;
      }
      .fmt-color-trigger:hover {
        background: rgba(var(--primary-rgb), 0.15);
        border-color: rgba(var(--primary-rgb), 0.3);
      }
      .fmt-palette {
        display: none;
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        background: var(--card-bg);
        border: 1px solid rgba(var(--primary-rgb), 0.3);
        border-radius: var(--radius-md);
        padding: 10px 12px;
        z-index: var(--z-sticky);
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
        min-width: 220px;
        margin-top: 4px;
      }
      .fmt-palette.active {
        display: block;
      }
      .fmt-palette-title {
        font-size: var(--fs-sm);
        color: rgba(255, 255, 255, 0.6);
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-bottom: 6px;
        text-align: center;
      }
      .fmt-palette-grid {
        display: flex;
        flex-direction: column;
        gap: 0;
      }
      .fmt-section-label {
        font-size: var(--fs-xs);
        color: rgba(255,255,255,0.45);
        text-transform: uppercase;
        letter-spacing: 0.8px;
        margin-bottom: 3px;
        padding-left: 1px;
      }
      .fmt-color-row {
        display: flex;
        gap: 2px;
        margin-bottom: 2px;
      }
      .fmt-palette-swatch {
        width: 19px;
        height: 19px;
        border-radius: var(--radius-xs);
        border: 1px solid transparent;
        cursor: pointer;
        transition: all 0.12s;
        flex-shrink: 0;
      }
      .fmt-palette-swatch:hover {
        border-color: var(--text-main);
        transform: scale(1.25);
        z-index: var(--z-above);
        box-shadow: 0 0 6px rgba(255,255,255,0.3);
      }
      /* Table Insert Modal */
      .table-insert-popup {
        position: absolute;
        top: 100%;
        left: 0;
        background: var(--card-bg);
        border: 1px solid rgba(var(--primary-rgb), 0.3);
        border-radius: var(--radius-md);
        padding: 14px;
        z-index: var(--z-sticky);
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
        display: none;
        min-width: 200px;
      }
      .table-insert-popup.active {
        display: block;
      }
      .table-insert-popup label {
        display: flex;
        align-items: center;
        gap: 8px;
        color: rgba(255, 255, 255, 0.8);
        font-size: var(--fs-base);
        margin-bottom: 8px;
      }
      .table-insert-popup input[type="number"] {
        width: 50px;
        padding: 4px 6px;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: var(--radius-sm);
        color: var(--text-main);
        font-size: var(--fs-base);
        text-align: center;
      }
      .table-insert-popup button {
        width: 100%;
        padding: 6px;
        background: linear-gradient(135deg, var(--primary), var(--secondary));
        border: none;
        color: var(--text-main);
        border-radius: var(--radius-sm);
        cursor: pointer;
        font-size: var(--fs-base);
        font-weight: 600;
        margin-top: 4px;
      }
      .table-insert-popup button:hover {
        opacity: 0.9;
      }

/* ── Editor Container, Find & Replace, Content Area, Preview Area ── */
      .editor-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        position: relative;
        overflow-y: hidden;
        overflow-x: hidden;
        min-height: 0;
      }
      /* ── Find & Replace Bar ─────────────────────────────── */
      .find-replace-bar {
        display: none;
        flex-direction: column;
        gap: 6px;
        padding: 8px 12px;
        background: var(--card-bg-solid);
        border-bottom: 1px solid var(--glass-border);
        backdrop-filter: blur(12px);
        z-index: var(--z-dropdown);
        flex-shrink: 0;
      }
      .find-replace-bar.active {
        display: flex;
      }
      .fr-row {
        display: flex;
        align-items: center;
        gap: 6px;
      }
      .fr-row input {
        flex: 1;
        background: rgba(255,255,255,0.06);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-sm);
        color: var(--text-main);
        padding: 5px 10px;
        font-size: var(--fs-base);
        font-family: var(--font-main);
        outline: none;
        min-width: 0;
      }
      .fr-row input:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
      }
      .fr-row input::placeholder {
        color: var(--text-dim);
      }
      .fr-count {
        font-size: var(--fs-sm);
        color: var(--text-dim);
        white-space: nowrap;
        min-width: 36px;
        text-align: center;
      }
      .fr-btn {
        background: rgba(255,255,255,0.06);
        border: 1px solid var(--glass-border);
        color: var(--text-dim);
        border-radius: var(--radius-sm);
        cursor: pointer;
        font-size: var(--fs-sm);
        padding: 4px 8px;
        white-space: nowrap;
        transition: background 0.15s, color 0.15s;
      }
      .fr-btn:hover {
        background: rgba(var(--primary-rgb), 0.2);
        color: var(--text-main);
      }
      .fr-btn.fr-nav {
        width: 26px;
        height: 26px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: var(--fs-sm);
      }
      .fr-btn.fr-close-btn {
        width: 26px;
        height: 26px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: var(--fs-base);
      }
      .fr-match {
        background: rgba(255, 220, 0, 0.25);
        border-radius: var(--radius-xs);
      }
      .fr-match.fr-current {
        background: rgba(255, 220, 0, 0.6);
        outline: 2px solid rgba(255, 215, 0, 0.8);
        border-radius: var(--radius-xs);
      }
      .content-area {
        flex: 1;
        background: transparent;
        border: none;
        color: var(--text-dim);
        font-size: var(--fs-md);
        line-height: 1.75;
        resize: none;
        font-family: inherit;
      }
      .content-area:focus:not(:focus-visible) { outline: none; }
      .content-area::placeholder {
        color: rgba(255, 255, 255, 0.15);
      }
      .preview-area {
        flex: 1;
        overflow-y: auto;
        font-size: var(--fs-md);
        line-height: 1.8;
        color: var(--text-dim);
        padding: 8px 10px;
        cursor: text;
        border-radius: var(--radius-base);
        transition: box-shadow 0.2s;
        background: var(--card-bg);
      }
      .preview-area:focus:not(:focus-visible) { outline: none; }
      .preview-area a {
        color: var(--primary);
        text-decoration: underline;
        text-decoration-color: rgba(var(--primary-rgb), 0.4);
      }
      .preview-area a:hover {
        text-decoration-color: var(--primary);
      }
      .preview-area:focus {
        box-shadow: 0 0 0 1px rgba(var(--primary-rgb), 0.3);
      }
      .preview-area:empty::before {
        content: attr(data-placeholder);
        color: rgba(255, 255, 255, 0.2);
        pointer-events: none;
      }
      .preview-area::-webkit-scrollbar {
        width: 4px;
      }
      .preview-area::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.1);
        border-radius: var(--radius-xs);
      }
      body.light-mode .preview-area::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.12); border-radius: var(--radius-xs); }
      body.light-mode .preview-area::-webkit-scrollbar-track { background: transparent; }

      /* ── Reading Width (compact editor) ─────────────── */
      .preview-area.reading-width {
        width: 75%;
        max-width: 1152px;
        margin: 0 auto;
      }


/* ── Light mode: Tool buttons + Format buttons ── */
      body.light-mode .tool-btn {
        background: rgba(0, 0, 0, 0.04) !important;
        border-color: rgba(0, 0, 0, 0.12) !important;
        color: var(--text-muted) !important;
      }
      body.light-mode .tool-btn:hover {
        background: rgba(var(--primary-rgb), 0.1) !important;
        color: var(--primary-dark) !important;
        border-color: rgba(var(--primary-rgb), 0.3) !important;
      }
      body.light-mode .fmt-btn {
        color: var(--text-main) !important;
      }
      body.light-mode .fmt-btn:hover {
        background: rgba(var(--primary-rgb), 0.12) !important;
        color: var(--primary-dark) !important;
        border-color: rgba(var(--primary-rgb), 0.25) !important;
      }
      body.light-mode .fmt-select {
        background: rgba(0,0,0,0.05) !important;
        border-color: rgba(0,0,0,0.15) !important;
        color: var(--text-main) !important;
      }
      body.light-mode .fmt-select option {
        background: var(--card-bg-solid) !important;
        color: var(--text-main) !important;
      }
      body.light-mode .fmt-separator {
        background: rgba(0,0,0,0.12) !important;
      }

/* ── Light mode: Editor toolbar ── */
      /* ── Light mode: Editor toolbar ── */
      body.light-mode .editor-title-row {
        color: var(--text-main) !important;
      }

/* ── Light mode: Format toolbar + Table insert ── */
      /* ── Light mode: Format toolbar ── */
      body.light-mode .format-toolbar {
        background: rgba(0,0,0,0.03) !important;
        border-color: rgba(0,0,0,0.08) !important;
      }
      body.light-mode .format-toolbar:hover {
        background: rgba(0,0,0,0.05) !important;
        border-color: rgba(var(--primary-rgb),0.2) !important;
      }
      body.light-mode .fmt-color-trigger {
        color: var(--text-muted) !important;
      }
      body.light-mode .fmt-palette {
        background: var(--card-bg-solid) !important;
        border-color: rgba(var(--primary-rgb),0.2) !important;
        box-shadow: 0 8px 30px rgba(0,0,0,0.15) !important;
      }
      body.light-mode .fmt-palette-title {
        color: var(--text-muted) !important;
      }
      body.light-mode .fmt-palette-swatch:hover {
        border-color: var(--text-main) !important;
        box-shadow: 0 0 6px rgba(0,0,0,0.2) !important;
      }
      body.light-mode .fmt-section-label {
        color: rgba(0,0,0,0.4) !important;
      }
      body.light-mode .table-insert-popup {
        background: var(--card-bg-solid) !important;
        border-color: rgba(var(--primary-rgb),0.2) !important;
        box-shadow: 0 8px 30px rgba(0,0,0,0.15) !important;
      }
      body.light-mode .table-insert-popup label {
        color: var(--text-main) !important;
      }
      body.light-mode .table-insert-popup input[type="number"] {
        background: rgba(0,0,0,0.04) !important;
        border-color: rgba(0,0,0,0.12) !important;
        color: var(--text-main) !important;
      }

/* ── Light mode: Content area / Editor / Find & Replace ── */
      /* ── Light mode: Content area / Editor ── */
      body.light-mode .content-area {
        color: var(--text-main) !important;
      }
      body.light-mode .content-area::placeholder {
        color: rgba(0,0,0,0.2) !important;
      }
      body.light-mode .editor-title {
        color: var(--text-main) !important;
      }
      body.light-mode .editor-title:focus,
      body.light-mode .editor-title:focus-visible {
        outline: revert;
        box-shadow: 0 0 0 1px rgba(0,0,0,0.18) !important;
        border-radius: var(--radius-sm) !important;
      }
      body.light-mode .editor-title::placeholder {
        color: rgba(0,0,0,0.25) !important;
      }
      body.light-mode .preview-area {
        color: var(--text-main) !important;
        border: 1px solid rgba(0,0,0,0.22) !important;
        box-shadow: none !important;
      }
      body.light-mode .preview-area:focus,
      body.light-mode .preview-area:focus-visible {
        outline: revert;
        border: 1px solid rgba(0,0,0,0.4) !important;
        box-shadow: none !important;
      }
      body.light-mode .preview-area:empty::before {
        color: rgba(0,0,0,0.25) !important;
      }
      body.light-mode .word-count {
        color: var(--text-muted) !important;
      }

      /* ── Light mode: Find & Replace ── */
      body.light-mode .find-replace-bar {
        background: rgba(240,244,255,0.95) !important;
        border-bottom-color: rgba(0,0,0,0.1) !important;
      }
      body.light-mode .fr-row input {
        background: rgba(0,0,0,0.04) !important;
        border-color: rgba(0,0,0,0.12) !important;
        color: var(--text-main) !important;
      }
      body.light-mode .fr-btn {
        background: rgba(0,0,0,0.04) !important;
        color: var(--text-muted) !important;
        border-color: rgba(0,0,0,0.1) !important;
      }
      body.light-mode .fr-btn:hover {
        background: rgba(var(--primary-rgb),0.15) !important;
        color: var(--text-main) !important;
      }

      /* ── Light mode: Version History modal (inline JS → #history-modal) ── */
      body.light-mode #history-modal > div {
        background: var(--card-bg-solid) !important;
        border-color: rgba(0,0,0,0.12) !important;
        box-shadow: 0 24px 64px rgba(0,0,0,0.18) !important;
        color: var(--text-main) !important;
      }
      body.light-mode #history-modal > div > div:first-child {
        border-bottom-color: rgba(0,0,0,0.1) !important;
      }
      body.light-mode #history-modal > div > div:nth-child(2) > div:first-child {
        border-right-color: rgba(0,0,0,0.1) !important;
      }
      body.light-mode #history-modal > div > div:last-child {
        border-top-color: rgba(0,0,0,0.1) !important;
      }
      body.light-mode #history-modal > div div[style*="border:1px solid rgba(255"] {
        border-color: rgba(0,0,0,0.1) !important;
      }
      body.light-mode #history-modal > div div[style*="border-bottom:1px solid rgba(255"] {
        border-bottom-color: rgba(0,0,0,0.08) !important;
      }


/* ── Floating Table of Contents (TOC) ──────────────────────── */
.gn-toc-panel {
    position: fixed;
    top: 60px;
    right: -280px;
    width: 260px;
    max-height: calc(100vh - 100px);
    background: var(--card-bg-solid, #141b2d);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: var(--z-dropdown);
    display: flex;
    flex-direction: column;
    transition: right 0.25s ease;
    overflow: hidden;
}
.gn-toc-panel.active {
    right: 16px;
}
.gn-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-sm) var(--sp-md);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}
.gn-toc-title {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: 0.02em;
}
.gn-toc-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: var(--fs-lg);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    border-radius: var(--radius-xs);
    transition: color 0.15s, background 0.15s;
}
.gn-toc-close:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
}
.gn-toc-list {
    overflow-y: auto;
    padding: var(--sp-sm) 0;
    flex: 1;
}
.gn-toc-list::-webkit-scrollbar { width: 4px; }
.gn-toc-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: var(--radius-xs); }
.gn-toc-empty {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    padding: var(--sp-md);
}
.gn-toc-item {
    display: block;
    padding: 5px var(--sp-md);
    font-size: var(--fs-sm);
    color: var(--text-dim);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: var(--radius-xs);
    transition: color 0.15s, background 0.15s;
}
.gn-toc-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}
.gn-toc-level-0 { padding-left: var(--sp-md); font-weight: 600; }
.gn-toc-level-1 { padding-left: calc(var(--sp-md) + 14px); }
.gn-toc-level-2 { padding-left: calc(var(--sp-md) + 28px); font-size: var(--fs-xs); }

/* Light mode */
body.light-mode .gn-toc-panel {
    background: var(--card-bg-solid);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
body.light-mode .gn-toc-close:hover { background: rgba(0, 0, 0, 0.06); }
body.light-mode .gn-toc-item:hover { background: rgba(0, 0, 0, 0.04); }
body.light-mode .gn-toc-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); }


/* ── Editor status bar ──────────────────────────── */
.editor-status-bar {
    display: flex;
    justify-content: flex-end;
    padding: 4px 12px;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    opacity: 0.6;
}
.editor-status-modified { margin-right: auto; }
.editor-checkbox { margin-right: 6px; }

/* ── Block Drag & Drop ─────────────────────────── */
.block-drag-handle {
    position: absolute;
    left: -28px;
    top: 2px;
    width: 20px;
    height: 20px;
    cursor: grab;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-base);
    color: var(--text-dim);
    border-radius: var(--radius-xs);
    transition: opacity 0.15s;
    z-index: var(--z-sidebar);
    user-select: none;
}
.block-drop-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
    border-radius: var(--radius-xs);
    pointer-events: none;
    display: none;
    z-index: var(--z-sidebar);
    transition: top 0.08s;
}

/* ── Table / Editor context menu (reuses .gn-ctx-menu) ── */
.table-context-menu {
    position: fixed;
    z-index: var(--z-dropdown);
    display: none;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-base);
    padding: 4px 0;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    backdrop-filter: blur(12px);
}

/* ── Image Resize Overlay ──────────────────────── */
.img-resize-overlay {
    position: absolute;
    pointer-events: none;
    border: 2px solid var(--primary);
    border-radius: var(--radius-xs);
    display: none;
    z-index: var(--z-sidebar);
}
.img-resize-corner {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: var(--radius-full);
    pointer-events: all;
}
.img-resize-corner[data-corner="nw"] { top: -5px; left: -5px; cursor: nwse-resize; }
.img-resize-corner[data-corner="ne"] { top: -5px; right: -5px; cursor: nesw-resize; }
.img-resize-corner[data-corner="sw"] { bottom: -5px; left: -5px; cursor: nesw-resize; }
.img-resize-corner[data-corner="se"] { bottom: -5px; right: -5px; cursor: nwse-resize; }

/* ── Slash command menu ────────────────────────── */
.slash-menu {
    position: fixed;
    z-index: var(--z-toast);
    max-height: 280px;
    overflow-y: auto;
    width: 220px;
    animation: gn-popup-in 0.2s both;
}

/* ── @mention menu ─────────────────────────────── */
.mention-menu {
    position: fixed;
    z-index: var(--z-toast);
    max-height: 300px;
    overflow-y: auto;
    width: 240px;
    animation: gn-popup-in 0.2s both;
}

/* ── Toolbar drag reorder ──────────────────────── */
.toolbar-drag-indicator {
    position: absolute;
    width: 2px;
    height: 20px;
    background: var(--primary, #6366f1);
    border-radius: var(--radius-xs);
    z-index: var(--z-toast);
    pointer-events: none;
    display: none;
    transition: left 0.08s, top 0.08s;
}
.toolbar-drag-ghost {
    position: fixed;
    z-index: var(--z-toast);
    pointer-events: none;
    opacity: 0.85;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    transform: scale(1.05);
    transition: none;
}

/* ── Selection quick-actions toolbar ───────────── */
#sel-toolbar {
    position: absolute;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-base);
    padding: 4px;
    display: flex;
    gap: 2px;
    z-index: var(--z-dropdown);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.sel-toolbar-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    font-size: var(--fs-base);
}

/* ─── TASK-1365: inline-style → CSS classes ──────────────────────────────── */
/* editor.js: stdLabel second section label needs top spacing */
.fmt-section-label--mt { margin-top: 6px; }

/* editor.js: @-mention search input font size */
#at-search-input { font-size: var(--fs-sm); }

/* editor.js: @-mention empty state */
.at-menu-empty { font-size: var(--fs-sm); }

/* editor.js: note properties info value */
.np-meta-val { color: var(--text-main); }

/* editor.js: note properties key input fixed width */
.np-key-input { flex: 0 0 120px; }

/* editor.js: background color button — default/reset state */
.fmt-bg-btn--default { background: rgba(var(--color-warning-rgb),0.3) !important; }

/* shared utility: position relative (for popup anchoring) */
.gn-pos-relative { position: relative; }

/* editor.js: @-mention menu item icon (flex-shrink) */
.at-item-icon { flex-shrink: 0; }

/* editor.js: color swatches — border for black/white swatches */
.fmt-palette-swatch--dark  { border: 1px solid rgba(255,255,255,0.2) !important; }
.fmt-palette-swatch--light { border: 1px solid rgba(0,0,0,0.2) !important; }

/* editor.js: voice-to-text button — speaking/active state (replaces style.color) */
.editor-voice-btn--speaking { color: var(--color-success) !important; }

/* editor.js: editor right-click context menu min-width */
.editor-ctx-menu--wide { min-width: 210px; }

/* editor.js: callout type popup min-width */
.editor-callout-popup { min-width: 140px; }

/* editor.js: toolbar reorder mode — button active highlight */
.tool-btn--reorder-active { background: rgba(var(--primary-rgb), 0.25) !important; }
