
/* Editor wrapper - ensure proper positioning context */
.writingml-editor-v2-wrapper {
    position: relative;
    max-width: 100%;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Tighten toolbar button spacing */
.writingml-toolbar-v2 {
    line-height: 1; /* Reduce line height to prevent vertical gaps */
    font-size: 0; /* Remove whitespace between inline-block elements */
    background-color: #f2f4fa; /* Match SVG button background */
}

.writingml-toolbar-v2 .Editor_Button {
    font-size: initial; /* Reset font size for button content */
    margin: 0 -1px; /* Negative margin to overlap borders slightly */
    padding: 0; /* Remove padding for tighter fit */
    vertical-align: top; /* Align buttons properly */
    position: relative; /* Allow absolute positioning of child elements like color indicators */
}

.writingml-toolbar-v2 .Editor_Button img {
    display: block; /* Remove bottom gap from inline images */
    padding: 0px; /* Small padding around the icon */
}

/* Color indicators for toolbar buttons */
.writingml-toolbar-v2 .Editor_Button .color-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    pointer-events: none; /* Don't interfere with button clicks */
}

/* Active button state - indicates formatting is enabled */
/* NOTE: Only applies to NON-SVG buttons - SVG buttons override below */
.writingml-toolbar-v2 .Editor_Button.active:not(.svg-button) {
    background-color: #e3f2fd; /* Light blue background */
    border-radius: 3px;
    box-shadow: inset 0 0 0 1px #2196F3; /* Blue border effect */
}

.writingml-toolbar-v2 .Editor_Button.active:not(.svg-button) img {
    opacity: 0.9;
    filter: brightness(0.9) contrast(1.1);
}

/* SVG Button System - Disable ALL CSS styling for SVG buttons */
/* SVG buttons use image states (inactive/hover/active) instead of CSS */
.writingml-toolbar-v2 .Editor_Button.svg-button,
.writingml-toolbar-v2 .Editor_Button.svg-button:hover,
.writingml-toolbar-v2 .Editor_Button.svg-button:active,
.writingml-toolbar-v2 .Editor_Button.svg-button.active {
    background-color: transparent !important;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 -1px !important;
}

.writingml-toolbar-v2 .Editor_Button.svg-button img,
.writingml-toolbar-v2 .Editor_Button.svg-button.active img {
    opacity: 1 !important;
    filter: none !important;
    transform: none !important;
    width: inherit !important;
    height: inherit !important;
}

/* Remove hover effects for SVG buttons - handled by image swap */
.writingml-toolbar-v2 .Editor_Button.svg-button:hover {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Color/Highlight buttons with active color background */
/* Shows a colored square behind the icon that shows through transparent areas */
.writingml-toolbar-v2 .Editor_Button {
    position: relative !important;
}

.writingml-toolbar-v2 .Editor_Button .button-color-background {
    position: absolute !important;
    width: 16px !important;
    height: 16px !important;
    bottom: 2px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    border-radius: 2px !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    z-index: -1 !important;
    pointer-events: none !important;
    box-sizing: border-box !important;
}

.writingml-toolbar-v2 .Editor_Button img {
    position: relative !important;
    z-index: 10 !important;
}

/* Ensure color/highlight buttons with color background don't show extra CSS styling */
.writingml-toolbar-v2 .Editor_Button.has-color-background {
    background-color: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.writingml-toolbar-v2 .Editor_Button.has-color-background img {
    opacity: 1 !important;
    filter: none !important;
}

/* Highlight active color/highlight in dropdown menus AND inline menus */
.writingml-dropdown-v2 .color-swatch.active-color,
.writingml-dropdown-v2 .highlight-swatch.active-color,
.inline-menu-container .color-swatch.active-color,
.inline-menu-container .highlight-swatch.active-color,
.inline-menu-container div.color-swatch.active-color,
.inline-menu-container div.highlight-swatch.active-color {
    box-sizing: border-box !important;
    border: 2px solid #007bff !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8), inset 0 0 5px rgba(0, 123, 255, 0.3) !important;
    z-index: 100 !important;
    position: relative !important;
}

/* Highlight active font/size/linespace options in dropdown menus AND inline menus */
.writingml-dropdown-v2 .font-option.active-option,
.writingml-dropdown-v2 .size-option.active-option,
.writingml-dropdown-v2 .linespace-option.active-option,
.inline-menu-container .font-option.active-option,
.inline-menu-container .size-option.active-option,
.inline-menu-container .linespace-option.active-option {
    background-color: #e3f2fd !important;
    border: 1px solid #2196F3 !important;
    font-weight: bold !important;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.25);
}

/* Inline menu button hover effects */
.inline-menu-container button:hover {
    background-color: #f0f0f0 !important;
    border-color: #999 !important;
    transition: all 0.2s ease;
}

.inline-menu-container button:active {
    background-color: #e0e0e0 !important;
    transform: translateY(1px);
}

/* Inline menu color swatch hover effects */
.inline-menu-container .color-swatch:hover,
.inline-menu-container .highlight-swatch:hover {
    border-color: #333 !important;
    transform: scale(1.1);
    transition: all 0.15s ease;
    z-index: 10;
}

/* Editor content area */
.writingml-editor-v2 {
    min-height: 100px;
    padding-bottom: 50px; /* Ensure space to click at bottom */
    cursor: text;
    outline: none;
    background: white;
}

/* Model-based editing mode: preserve newlines */
.writingml-editor-v2.model-mode-active {
    white-space: pre-wrap; /* Preserve newlines and wrap long lines - only in model mode */
}

/* Model-based editing in minimized state: override white-space */
.writingml-editor-v2.model-mode-active.is-minimized {
    white-space: nowrap !important; /* Keep single-line appearance when minimized */
    text-overflow: ellipsis !important;
}

/* Remove browser default outline on focus */
.writingml-editor-v2:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* ==================================================================
   MINIMIZED EDITOR STATE
   Clean class-based styling for editors that start small and expand
   ================================================================== */

/* Toolbar hidden when minimized */
.writingml-editor-v2-wrapper.is-minimized .writingml-toolbar-v2 {
    display: none;
}

/* Toolbar visible and animated when expanded */
.writingml-editor-v2-wrapper.is-expanded .writingml-toolbar-v2 {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

/* Editor in minimized state - compact textarea-like appearance */
.writingml-editor-v2.is-minimized {
    /* Size and overflow */
    height: 2.5em !important;
    min-height: 2.5em !important;
    max-height: 2.5em !important;
    overflow: hidden !important;
    
    /* Visual styling - subtle input-like appearance */
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    background: white !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05) !important;
    
    /* Text styling */
    color: #333 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    
    /* Spacing */
    padding: 8px 12px !important;
    margin: 8px 0 !important;
    
    /* Positioning for placeholder */
    position: relative;
    
    /* Smooth transitions */
    transition: all 0.25s ease-in-out;
}

/* Focus state for minimized editor - subtle highlight */
.writingml-editor-v2.is-minimized:focus {
    border-color: #4A90E2 !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05), 0 0 0 2px rgba(74, 144, 226, 0.1) !important;
    outline: none !important;
}

/* Editor in expanded state - full editor appearance */
.writingml-editor-v2.is-expanded {
    /* Size set by data-expanded-height via JavaScript */
    overflow-y: auto !important;
    resize: vertical !important;
    
    /* Visual styling */
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    background: white !important;
    box-shadow: none !important;
    
    /* Text styling */
    color: #000 !important;
    white-space: normal !important;
    text-overflow: clip !important;
    
    /* Spacing */
    padding: 10px !important;
    margin: 4px 0 !important;
    
    /* Smooth transitions */
    transition: all 0.25s ease-in-out;
}

/* Focus state for expanded editor */
.writingml-editor-v2.is-expanded:focus {
    outline: 2px solid #4A90E2 !important;
    outline-offset: -2px !important;
}

/* Placeholder for minimized editor - show when empty and not focused */
.writingml-editor-v2.is-minimized[data-placeholder]:empty:not(:focus)::before {
    content: attr(data-placeholder);
    color: #999;
    font-style: normal;
    pointer-events: none;
    position: absolute;
    top: 8px;
    left: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 24px);
}

/* Always hide placeholder when minimized editor is focused (even if browser adds BR) */
.writingml-editor-v2.is-minimized[data-placeholder]:focus::before {
    content: none !important;
    display: none !important;
}

/* Placeholder for expanded editor - show when empty and not focused */
.writingml-editor-v2.is-expanded[data-placeholder]:empty:not(:focus)::before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
    pointer-events: none;
    position: absolute;
    top: 10px;
    left: 10px;
}

/* Always hide placeholder when expanded editor is focused */
.writingml-editor-v2.is-expanded[data-placeholder]:focus::before {
    content: none !important;
    display: none !important;
}

/* Ensure content is positioned above placeholder */
.writingml-editor-v2.is-minimized > *,
.writingml-editor-v2.is-expanded > * {
    position: relative;
    z-index: 2;
}

/* Animation for toolbar fade-in */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================================================================
   LEGACY MINIMAL-INITIAL CLASS (Deprecated - for backward compatibility)
   ================================================================== */

/* Keep old minimal-initial class working for backward compatibility */
.writingml-editor-v2.minimal-initial {
    /* Redirect to new is-minimized styles */
    height: 2.5em !important;
    min-height: 2.5em !important;
    max-height: 2.5em !important;
    overflow: hidden !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    background: white !important;
    color: #333 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    padding: 8px 12px !important;
    margin: 8px 0 !important;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05) !important;
    transition: all 0.25s ease-in-out;
}

.writingml-editor-v2.minimal-initial:focus {
    border-color: #4A90E2 !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05), 0 0 0 2px rgba(74, 144, 226, 0.1) !important;
    outline: none !important;
}

.writingml-editor-v2.minimal-initial[data-placeholder]:empty:not(:focus)::before {
    content: attr(data-placeholder);
    color: #999;
    font-style: normal;
    pointer-events: none;
    position: absolute;
    top: 8px;
    left: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 24px);
}

/* Always hide placeholder when legacy minimal editor is focused */
.writingml-editor-v2.minimal-initial[data-placeholder]:focus::before {
    content: none !important;
    display: none !important;
}

.writingml-editor-v2.minimal-initial > * {
    position: relative;
    z-index: 2;
}

/* Ensure empty editor has clickable area - but not for minimal initial state */
.writingml-editor-v2:not(.minimal-initial):empty::before {
    content: '\200B'; /* Zero-width space */
    display: inline;
}

/* Dropdown menus */
.writingml-dropdown-v2 {
    position: fixed;
    background: #f2f4fa;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 0;
    min-width: 200px;
    max-width: 550px;
    min-height: 65px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 10000;
}

/* Color menus should fit their content */
#highlight-menu-writingml_editor,
[id^="highlight-menu-"],
#color-menu-writingml_editor,
[id^="color-menu-"] {
    min-width: 440px;  /* Force wider layout */
    width: auto;  /* Let it size to content */
}

.writingml-dropdown-v2 .dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    font-weight: bold;
    background: #f2f4fa;
}

.writingml-dropdown-v2 .close-btn {
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: #666;
    padding: 0 5px;
}

.writingml-dropdown-v2 .close-btn:hover {
    color: #333;
}

/* Color grids - using flexbox */
.color-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;  /* Center horizontally */
    align-content: center;  /* Center when fits, top when scrolling */
    gap: 5px;
    padding: 8px;
    background: #f2f4fa;
}


.color-swatch {
    width: 36px;
    height: 36px;
    border: 2px solid #ddd;
    cursor: pointer;
    border-radius: 3px;
}

.color-swatch:hover {
    border-color: #333;
}

.color-swatch.active {
    border: 2px solid #2196F3;
    box-shadow: 0 0 0 2px white, 0 0 0 3px #2196F3;
}

/* Default/Clear color swatch styling */
.color-swatch-default {
    position: relative;
}

.color-swatch-default:hover {
    border-color: #2196F3 !important;
    box-shadow: 0 0 0 1px #2196F3;
}

/* Size options */
.size-options {
    padding: 5px 0;
    background: #f2f4fa;
}

.size-option {
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 0;
    text-align: left;
}

.size-option:hover {
    background: #e3f2fd;
}

.size-option.active {
    background: #e3f2fd;
    border-left: 3px solid #2196F3;
    font-weight: bold;
}

/* Line spacing options */
.linespace-options {
    padding: 5px 0;
    background: #f2f4fa;
}

.linespace-option {
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 0;
    text-align: left;
}

.linespace-option:hover {
    background: #e3f2fd;
}

.linespace-option.active {
    background: #e3f2fd;
    border-left: 3px solid #2196F3;
    font-weight: bold;
}

/* Alignment options */
.alignment-options {
    padding: 5px 0;
    background: #f2f4fa;
}

.alignment-option {
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

.alignment-option img {
    display: block;
    width: 20px;
    height: 18px;
    flex-shrink: 0;
}

.alignment-option span {
    font-size: 14px;
    color: #333;
    flex: 1;
}

.alignment-option:hover {
    background: #e3f2fd;
}

.alignment-option.active {
    background: #e3f2fd;
    border-left: 3px solid #2196F3;
    font-weight: bold;
}

/* Inline alignment options - horizontal layout */
.writingml-inline-options .alignment-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px;
    background: #f2f4fa;
}

.writingml-inline-options .alignment-option {
    padding: 10px 8px;
    text-align: center;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
}

.writingml-inline-options .alignment-option:hover {
    background: #e3f2fd;
    border-color: #2196F3;
}

.writingml-inline-options .alignment-option img {
    width: 20px;
    height: 18px;
}

.writingml-inline-options .alignment-option span {
    font-size: 12px;
}

/* Font options */
.font-options {
    padding: 5px 0;
    max-height: 300px;
    overflow-y: auto;
    background: #f2f4fa;
}

.font-option {
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 0;
    text-align: left;
}

.font-option:hover {
    background: #e3f2fd;
}

.font-option.active {
    background: #e3f2fd;
    border-left: 3px solid #2196F3;
    font-weight: bold;
}

/* Special formatting options */
.writingml-dropdown-v2 .special-options,
.inline-menu-container .special-options {
    padding: 5px 0;
    background: #f2f4fa;
}

.writingml-dropdown-v2 .special-option,
.inline-menu-container .special-option {
    padding: 10px 15px;
    cursor: pointer;
    display: block;
    border-radius: 0;
    text-align: left;
}

.writingml-dropdown-v2 .special-option:hover,
.inline-menu-container .special-option:hover {
    background: #e3f2fd;
}

.writingml-dropdown-v2 .special-option .option-title,
.inline-menu-container .special-option .option-title {
    display: block !important;
    font-weight: bold;
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}

.writingml-dropdown-v2 .special-option .option-desc,
.inline-menu-container .special-option .option-desc {
    display: block !important;
    font-size: 12px;
    color: #666;
    line-height: 1.3;
    margin-top: 2px;
}

/* Inline special/creative tools options - grid layout */
.writingml-inline-options .special-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 8px;
    background: #f2f4fa;
    max-height: 200px;
    overflow-y: auto;
}

.writingml-inline-options .special-option {
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 3px;
    min-height: 50px;
    cursor: pointer;
}

.writingml-inline-options .special-option:hover {
    background: #e3f2fd;
    border-color: #2196F3;
}

.writingml-inline-options .special-option .option-title {
    font-size: 13px;
    line-height: 1.3;
}

.writingml-inline-options .special-option .option-desc {
    font-size: 11px;
    line-height: 1.2;
    margin-top: 2px;
}

/* Quick Text (Macro) options */
.macro-options {
    padding: 5px 0;
    background: #f2f4fa;
}

.writingml-macro-item {
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 0;
    display: block;
    text-align: left;
}

.writingml-macro-item:hover {
    background: #e3f2fd;
}

.writingml-macro-item .macro-name {
    font-size: 14px;
    color: #333;
}

.writingml-macro-item .macro-shortcut {
    font-size: 11px;
    color: #999;
    margin-left: 8px;
}

/* Giphy menu */
.giphy-menu {
    /* Width is set dynamically in JS based on editor width */
    max-width: 90vw;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.12);
    border: 1px solid rgba(0,0,0,0.08);
    opacity: 1;
}

.giphy-menu[style*="visibility: hidden"] {
    opacity: 0;
}

.giphy-search {
    display: flex;
    gap: 8px;
    align-items: center;
}

.giphy-search-input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
    transition: border-color 0.2s;
}

.giphy-search-input:focus {
    outline: none;
    border-color: #2196F3;
}

.giphy-search-input.has-suggestions {
    border-color: #2196F3;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.giphy-search-btn {
    padding: 6px 12px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

.giphy-search-btn:hover {
    background: #1976D2;
}

.giphy-trending-btn {
    padding: 6px 12px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    margin-left: 4px;
}

.giphy-trending-btn:hover {
    background: #ff5252;
}

.giphy-suggestions {
    position: absolute;
    top: calc(100% - 1px);
    left: 0;
    width: 100%;
    max-width: 250px;
    background: #fff;
    border: 1px solid #2196F3;
    border-top: none;
    border-radius: 0 0 3px 3px;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10001;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    scroll-behavior: smooth;
}

.giphy-suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.1s;
}

.giphy-suggestion-item:last-child {
    border-bottom: none;
}

.giphy-suggestion-item:hover,
.giphy-suggestion-item.selected {
    background-color: #e3f2fd;
    color: #1976D2;
}

.giphy-suggestion-item.selected {
    background-color: #2196F3;
    color: white;
}

.giphy-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    padding: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.giphy-result-container {
    position: relative;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
    /* Maintain 16:10 aspect ratio for GIFs (close to typical GIF ratios) */
    aspect-ratio: 16 / 10;
}

.giphy-result {
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
}

.giphy-result img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Emoticon menu */
.emoticon-menu {
    width: 450px;
    max-width: 95vw;
    max-height: 500px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.emoticon-search {
    padding: 8px;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 5px;
    align-items: center;
}

.emoticon-search-input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
    box-sizing: border-box;
}

/* Color picker button */
.emoticon-color-picker-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: linear-gradient(to right, #ff0000, #ff8800, #ffff00, #00ff00, #0000ff, #8b00ff);
    cursor: pointer;
    position: relative;
}

.emoticon-color-picker-btn:hover {
    border-color: #999;
}

/* Color palette - inline display like V1 */
.emoticon-color-palette {
    display: none;
    padding: 8px;
    background: #f9f9f9;
}

.emoticon-color-swatches {
    display: flex;
    flex-wrap: nowrap; /* Keep colors in single row like V1 */
    gap: 3px;
    justify-content: center;
    align-items: center;
    padding: 4px;
    background: white;
    border-radius: 4px;
}

.emoticon-color-swatch {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 1px solid #000;
    border-radius: 4px;
    cursor: pointer;
    box-sizing: border-box;
}

.emoticon-color-swatch:hover {
    border: 2px solid #2196F3;
    transform: scale(1.1);
}

.emoticon-color-swatch.active {
    border: 2px solid #4CAF50;
    box-shadow: 0 0 0 1px #4CAF50;
}

/* Close button for color palette */
.emoticon-color-close {
    position: absolute;
    right: 5px;
    top: 5px;
    width: 20px;
    height: 20px;
    padding: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoticon-color-close:hover {
    background: #f0f0f0;
}

/* Categories with scroll limit */
.emoticon-categories {
    max-height: 80px;
    overflow-y: auto;
    padding: 8px;
    border-bottom: 1px solid #ddd;
    background: #f5f5f5;
}

.emoticon-categories.expanded {
    max-height: 200px;
}

.emoticon-categories-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.category-btn {
    padding: 4px 8px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.category-btn:hover,
.category-btn.active {
    background: #2196F3;
    color: white;
    border-color: #2196F3;
}

/* More button for categories */
.emoticon-categories-more {
    text-align: center;
    padding: 4px;
    font-size: 11px;
    color: #666;
    cursor: pointer;
    border-top: 1px solid #ddd;
    background: #f9f9f9;
    display: none;
}

.emoticon-categories-more:hover {
    background: #e8e8e8;
}

/* Custom scrollbar for categories */
.emoticon-categories::-webkit-scrollbar {
    width: 6px;
}

.emoticon-categories::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.emoticon-categories::-webkit-scrollbar-thumb {
    background: #999;
    border-radius: 3px;
}

/* Emoticon grid - contained within menu */
.emoticon-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(26px, 1fr));
    gap: 2px;
    padding: 5px;
    overflow-y: auto;
    overflow-x: hidden;
    background: white;
    min-height: 200px;
    scrollbar-width: thin;
    scrollbar-color: #999 #f5f5f5;
}

.emoticon-grid::-webkit-scrollbar {
    width: 8px;
}

.emoticon-grid::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.emoticon-grid::-webkit-scrollbar-thumb {
    background: #999;
    border-radius: 4px;
}

.emoticon-item {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 3px;
    transition: all 0.15s;
    padding: 3px;
}

.emoticon-item:hover {
    background-color: #e8f4f8;
    border-color: #b3d9e6;
    transform: scale(1.15);
    z-index: 1;
}

.emoticon-item img {
    width: 15px;
    height: 15px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
}

.emoticon-no-results {
    padding: 20px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* Mobile sizing for emoticons - REMOVED - See updated version below */
/* This section intentionally left empty to avoid conflicts */


/* High contrast mode support for accessibility */
@media (prefers-contrast: high) {
    .writingml-editor-v2.mobile-expanded {
        border-width: 3px;
    }
    
    .writingml-dropdown-v2,
    .emoticon-menu,
    .giphy-menu {
        border-width: 2px;
        border-color: currentColor;
    }
}

/* Preserved WritingML tags (em dash, en dash, indent) */
.writingml-emdash,
.writingml-endash,
.writingml-indent {
    display: inline;
    user-select: text;
    cursor: text;
    /* Ensure they don't block text flow */
    vertical-align: baseline;
}

/* When contenteditable=false, allow selection as a unit */
.writingml-emdash[contenteditable="false"],
.writingml-endash[contenteditable="false"],
.writingml-indent[contenteditable="false"] {
    display: inline;
    user-select: all;
    /* Allow cursor to move around them naturally */
    pointer-events: none;
}

/* Center alignment for elements within the editor only */
.writingml-editor-v2 div[align="center"],
.writingml-editor-v2 .center {
    text-align: center;
}

/* Emoticon line tags - wrapper is block with auto margins for centering */
.writingml-line-wrapper {
    display: block !important;
    /* Width set via inline style from line tag parameter */
    max-width: 100%;
    margin: 0 auto !important; /* Simplified margin declaration */
    text-align: left; /* Reset text alignment for content inside */
    position: relative; /* For better selection boundaries */
    box-sizing: border-box; /* Ensure padding/border doesn't affect width */
}

/* Force all content inside wrapper to be full width */
.writingml-line-wrapper > *,
.writingml-line-wrapper a,
.writingml-line-wrapper table {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
    text-decoration: none;
}

/* Special handling for tables to ensure they behave properly */
.writingml-line-wrapper table {
    display: table !important;
}

/* When line wrapper is selected, ensure selection doesn't extend beyond it */
.writingml-line-wrapper::selection,
.writingml-line-wrapper *::selection {
    background: rgba(179, 217, 255, 0.99);
}

.writingml-line-wrapper[contenteditable="false"],
.writingml-line-processed[contenteditable="false"] {
    user-select: all; /* Select the whole element when clicked */
    cursor: default;
    -webkit-user-select: all;
    -moz-user-select: all;
    -ms-user-select: all;
}

/* Line tag loading state */
.writingml-line-loading {
    display: inline-block;
    min-height: 20px;
    padding: 4px;
    background: #f9f9f9;
    border: 1px dashed #ccc;
    border-radius: 3px;
    text-align: center;
    color: #666;
    font-size: 12px;
    opacity: 0.6;
    cursor: wait;
}

/* Line tag processed state */
.writingml-line-processed {
    display: block;
    width: 100%;
}

/* WritingML pre tag - preformatted text */
.writingml-pre {
    display: block;
    white-space: pre-wrap; /* Preserve whitespace and wrap long lines */
    font-family: monospace;
    margin: 1em 0;
}

/* WritingML quote tag - blockquote */
.writingml-quote {
    display: block;
    margin: 1em 40px;
}

/* WritingML dropnote - collapsible note section */
.writingml-dropnote {
    display: block;
    margin: 0.5em 0;
}

.writingml-dropnote-trigger {
    color: #0066cc;
    text-decoration: underline;
    cursor: pointer;
    user-select: none;
    display: inline-block;
}

.writingml-dropnote-trigger:hover {
    color: #0052a3;
    text-decoration: underline;
    background-color: rgba(0, 102, 204, 0.05);
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.dropnote-arrow {
    font-size: 0.9em;
    display: inline-block;
    margin-left: 2px;
}

.writingml-dropnote-content {
    display: none;
    margin-top: 8px;
    padding: 12px;
    background: #f8f9fa;
    border-left: 3px solid #0066cc;
    border-radius: 4px;
    min-height: 20px;
    visibility: visible;
    opacity: 1;
}

/* NOTE: The old “block borders” helper has been refactored to gutter indicators.
   The visuals now live in editor.css under `.ProseMirror.editor-show-block-borders`. */

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .writingml-editor-v2,
    .writingml-dropdown-v2,
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* Google Docs-style Toolbar Tooltips */
/* z-index must be higher than overlay editor (2147483641) to show in sub-editors */
.writingml-toolbar-tooltip {
    position: fixed;
    background: #444;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    z-index: 2147483647;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    animation: tooltipFadeIn 0.15s ease-out;
}

/* Disable animation for fast-follow tooltips */
.writingml-toolbar-tooltip.no-animation {
    animation: none;
}

/* Feedback mode - for action blocked messages */
.writingml-toolbar-tooltip.feedback-mode {
    background: #2196F3;
    color: #fff;
    padding: 8px 14px;
    font-weight: 500;
    box-shadow: 0 3px 8px rgba(33, 150, 243, 0.4);
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

