.editor-kyst {
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 20px;
    /* max-width: 1400px; */
    margin: 0 auto;
    padding: 24px 20px;
    width: 100%;
    background-color: transparent;
    height: 100vh;
    overflow: hidden;
}

/* Visão expandida: remove max-width */
.main-content.expanded .editor-kyst {
    max-width: none;
}

.editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border: 1px solid var(--border-docs);
    border-radius: 8px;
    padding: 40px 60px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.editor-summary {
    width: 280px;
    background: var(--bg-primary);
    border: 1px solid var(--border-docs);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    height: fit-content;
    max-height: calc(100vh - 80px);
    position: sticky;
    top: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.summary-header {
    padding: 10px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.summary-title {
    flex: 1;
}

.summary-header-actions {
    display: flex;
    gap: 4px;
}

.summary-header-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.summary-header-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.summary-toggle-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-primary);
    border: 1px solid var(--border-docs);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transition: background 0.15s, color 0.15s;
}

.summary-toggle-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.summary-content {
    overflow-y: auto;
    padding: 8px 0;
}

.summary-item {
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    transition: background 0.2s;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
    position: relative;
}

.summary-item:hover {
    background: var(--bg-secondary);
}

.summary-item.level-2 {
    padding-left: 28px;
    font-size: 0.82rem;
}

.summary-item.level-3 {
    padding-left: 40px;
    font-size: 0.8rem;
}

.summary-item.level-4 {
    padding-left: 52px;
    font-size: 0.78rem;
}

.summary-item.level-5 {
    padding-left: 64px;
    font-size: 0.76rem;
}

.summary-hidden {
    display: none !important;
}

.summary-arrow {
    color: var(--accent);
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.5;
    min-width: 25px;
    text-align: center;
    user-select: none;
    
}

.summary-arrow:hover {
    opacity: 0.8;
}

.summary-arrow.has-children {
    cursor: pointer;
    opacity: 0.8;
    border: 1px solid var(--border-docs);
}

.summary-arrow.has-children:hover {
    opacity: 1;
}

.summary-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.summary-level-controls {
    display: none;
    align-items: center;
    gap: 2px;
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-primary);
    padding: 2px 4px;
    border-radius: 4px;
    box-shadow: 0 0 4px rgba(0,0,0,0.15);
}

.summary-item:hover .summary-level-controls {
    display: inline-flex;
}

.summary-level-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 10px;
    padding: 0 4px;
    line-height: 18px;
    transition: background 0.15s, color 0.15s;
}

.summary-level-btn:hover:not(:disabled) {
    background: var(--bg-secondary);
    color: var(--accent);
}

.summary-level-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.summary-level-num {
    font-size: 10px;
    color: var(--text-secondary);
    min-width: 12px;
    text-align: center;
}

.block-container {
    position: relative;
}

.alert-icon {
    font-size: 1rem !important;
}

.block-pin-indicator {
    position: absolute;
    left: -30px;
    top: 5px;
    transform: translateY(-50%);
    color: var(--accent);
    font-size: 12px;
    opacity: 0.8;
    pointer-events: none;
    transition: transform 0.2s;
}

.block-controls {
    background: #f7f7f796;
    border: 1px solid #dfdfdf;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: absolute;
    top: 4px;
    right: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 30;
    flex-direction: row;
}

.block-control-btn.save-btn {
    background: #eef2ff;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    height: 24px;
    display: flex;
    align-items: center;
}

.block-control-btn.save-btn:hover {
    background: var(--accent);
    color: white;
}

.block-control-btn.edit-btn {
    background: #f7f7f7e6;
    color: var(--text-secondary);
    border: 1px solid #e3e3e3;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    height: 24px;
    display: flex;
    align-items: center;
}

.block-control-btn.edit-btn:hover {
    background: #f0f0f0;
    color: var(--text-primary);
}

.block-delete-btn {
    background: #f7f7f7e6;
    border: 1px solid #e3e3e3;
    color: #e34444;
    cursor: pointer;
    font-size: 16px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.block-delete-btn:hover {
    background: #fff1f0;
}

.pin-btn,
.pin-level-btn {
    background: #f7f7f7e6;
    color: #2c2c2c;
    border: 1px solid #e3e3e3;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-btn:hover,
.pin-level-btn:not(.disabled):hover {
    background: #f0f0f0;
}

.pin-btn.active {
    background: #eef2ff;
    color: var(--accent);
}

.pin-level-display {
    font-size: 10px;
    border-right: 1px solid #e9e9e9;
    font-weight: 600;
    color: #787878;
    display: flex;
    align-items: center;
    min-width: 14px;
    margin-right: 5px;
    padding-right: 5px;
    justify-content: center;
}

.pin-level-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.editor-header {
    margin-bottom: 24px;
}

.doc-title-input {
    width: 100%;
    font-size: 2.5rem;
    font-weight: 700;
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
}

.editor-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    counter-reset: list-item;
}

.block-wrapper {
    position: relative;
}

/* Remote users indicator on blocks */
.block-wrapper.has-remote-users > .block-container {
    border: 2px solid var(--accent);
    border-radius: 8px;
    transition: border-color 0.2s ease;
}

.remote-users-indicator {
    position: absolute;
    top: -14px;
    right: 8px;
    z-index: 10;
    pointer-events: auto;
}

.remote-users-avatars {
    display: flex;
    gap: 4px;
}

.remote-user-avatar {
    position: relative;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border: 2px solid var(--accent);
    background: var(--bg-primary);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    cursor: default;
    overflow: visible;
}

.remote-user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.remote-user-initial {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.remote-user-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary, #333);
    color: var(--text-primary, #fff);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.remote-user-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--bg-tertiary, #333);
}

.remote-user-avatar:hover .remote-user-tooltip {
    opacity: 1;
}

.loading {
    color: var(--text-secondary);
    padding: 20px;
    text-align: center;
}

.block-insert-zone {
    height: 8px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: -4px 0;
    z-index: 5;
}

.block-insert-btn {
    opacity: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px dashed var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.block-insert-zone:hover .block-insert-btn {
    opacity: 1;
}

.block-insert-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: scale(1.1);
}

.block-insert-zone-bottom {
    height: 40px;
    margin: 0;
    padding-top: 10px;
}

.editor-no-document {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    background: var(--bg-primary);
}

.no-document-content {
    text-align: center;
    padding: 40px;
    max-width: 400px;
}

.no-document-icon {
    color: var(--text-tertiary);
    margin-bottom: 24px;
    opacity: 0.6;
}

.no-document-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.no-document-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* WYSIWYG Mode Styles - unified for editing and viewing */
.wysiwyg-mode {
    font-family: inherit;
    line-height: 1.6;
    color: var(--text-primary);
}

.wysiwyg-mode p:first-child {
    margin-top: 0;
}

.wysiwyg-mode p:last-child {
    margin-bottom: 0;
}

.wysiwyg-mode p {
    margin-bottom: 0.5em;
}

.wysiwyg-mode h1 {
    font-size: 2em;
    font-weight: bold;
    margin: 0.67em 0;
}

.wysiwyg-mode h2 {
    font-size: 1.5em;
    font-weight: bold;
    margin: 0.75em 0;
}

.wysiwyg-mode h3 {
    font-size: 1.17em;
    font-weight: bold;
    margin: 0.83em 0;
}

.wysiwyg-mode ul,
.wysiwyg-mode ol {
    padding-left: 2em;
    margin-bottom: 1em;
}

.wysiwyg-mode li {
    margin-bottom: 0.25em;
}

.wysiwyg-mode code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Fira Code', 'Cascadia Code', 'Source Code Pro', monospace;
    font-size: 0.9em;
}

.wysiwyg-mode blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1em;
    margin-left: 0;
    color: var(--text-secondary);
    font-style: italic;
}

.wysiwyg-mode a {
    color: #337aea;
    text-decoration: underline;
    cursor: pointer;
}

.wysiwyg-mode a:hover {
    opacity: 0.8;
}

.manual-save-btn {
    position: absolute;
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 100;
    transition: transform 0.1s;
}

.manual-save-btn:hover {
    transform: translateY(-50%) scale(1.1);
    background: #45a049;
}

.alert-editor.wysiwyg-mode p:first-child {
    margin-top: 0;
}

.alert-editor.wysiwyg-mode p:last-child {
    margin-bottom: 0;
}

/* Editor Top Actions Bar */
.editor-top-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 24px;
}

.editor-controls-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-docs);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.control-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.08);
}

.control-btn .material-icons {
    font-size: 1.1rem;
}

/* Markdown Import Modal Specifics */
.md-import-modal {
    max-width: 600px;
    width: 95%;
}

.md-textarea {
    font-family: 'Fira Code', 'Cascadia Code', 'Source Code Pro', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 200px;
}

/* ==========================================================================
   Todo Block (TodoItem)
   ========================================================================== */

.todo-checkbox-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 4px;
    /* Align with first line of text */
    flex-shrink: 0;
    user-select: none;
}

.todo-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-docs, #ddd);
    border-radius: 4px;
    background-color: var(--bg-primary, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin: 0;
}

.todo-checkbox:hover {
    border-color: var(--accent, #3b82f6);
}

.todo-checkbox:checked {
    background-color: var(--accent, #3b82f6);
    border-color: var(--accent, #3b82f6);
}

.todo-checkbox:checked::after {
    content: "✓";
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.block-todo {
    /* Style the text when it is a todo block */
    min-height: 24px;
}

.block-todo:has(.todo-checkbox:checked)+.block-todo,
.text-block-container:has(.todo-checkbox:checked)>.block-todo {
    color: var(--text-secondary, #999);
    text-decoration: line-through;
}
/* ============================================================================
   Block Drag and Drop Styles
   ============================================================================ */

.block-drag-handle {
    position: absolute;
    left: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.2s ease;
    color: var(--text-secondary, #999);
    border-radius: 4px;
    z-index: 10;
}

.block-drag-handle:hover {
    background: var(--bg-secondary, #f0f0f0);
    color: var(--text-primary, #333);
}

.block-drag-handle:active {
    cursor: grabbing;
}

.block-container:hover .block-drag-handle,
.block-wrapper:hover .block-drag-handle {
    opacity: 1;
}

.block-dragging {
    opacity: 0.5;
}

.block-drop-zone {
    height: 0px;
    /* margin: 2px 0; */
    border-radius: 2px;
    transition: all 0.15s ease;
    pointer-events: auto;
}

/* Expand all drop zones when dragging any block */
.editor-body.dragging .block-drop-zone {
    height: 15px;
    /* margin: 4px 0; */
    border: 1px dashed var(--border-docs, #ddd);
}

.block-drop-zone.active {
    height: 32px;
    background: var(--accent, #3b82f6);
    opacity: 0.3;
    /* margin: 4px 0; */
}

/* Active drop zone takes precedence */
.editor-body.dragging .block-drop-zone.active {
    height: 40px;
    background: var(--accent, #3b82f6);
    opacity: 0.5;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .block-drag-handle:hover {
        background: var(--bg-secondary, #3a3a3a);
        color: var(--text-primary, #eee);
    }
    
    .block-drop-zone.active {
        opacity: 0.4;
    }
}


/* ============================================================================
   Snapshot Modal Styles
   ============================================================================ */

.snapshot-modal {
    max-width: 500px;
    width: 90%;
}

.snapshot-list {
    max-height: 400px;
    overflow-y: auto;
    margin: 16px 0;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    padding: 8px;
}

.snapshot-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    transition: background-color 0.15s ease;
}

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

.snapshot-item:hover {
    background-color: var(--bg-hover, #f5f5f5);
    border-radius: 4px;
}

.snapshot-info {
    flex: 1;
    min-width: 0;
}

.snapshot-title {
    font-weight: 500;
    color: var(--text-primary, #333);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.snapshot-date {
    font-size: 12px;
    color: var(--text-secondary, #666);
}

.snapshot-empty {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary, #666);
    font-style: italic;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* Dark mode support for snapshot modal */
@media (prefers-color-scheme: dark) {
    .snapshot-list {
        border-color: var(--border-color, #444);
    }
    
    .snapshot-item {
        border-color: var(--border-color, #444);
    }
    
    .snapshot-item:hover {
        background-color: var(--bg-hover, #3a3a3a);
    }
    
    .snapshot-title {
        color: var(--text-primary, #eee);
    }
    
    .snapshot-date {
        color: var(--text-secondary, #aaa);
    }
    
    .snapshot-empty {
        color: var(--text-secondary, #aaa);
    }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .editor-kyst {
        padding: 8px;
        gap: 0;
    }

    .editor-main {
        padding: 16px 12px;
        border-radius: 0;
        border: none;
    }

    /* Hide the right summary panel on mobile */
    .editor-summary {
        display: none;
    }
}
