.notebook-section {
    padding: 16px;
    max-width: 800px;
    margin: 0 auto;
    padding-top: 60px;
}

.notebook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.notebook-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--tg-theme-text-color, var(--text-primary, #1a1a1a));
}

.notebook-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding: 4px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    border-radius: 12px;
}

.notebook-tab {
    flex: 1;
    padding: 10px 16px;
    border-radius: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--tg-theme-hint-color, var(--text-secondary, #666));
    transition: all 0.2s ease;
}

.notebook-tab.active {
    background: var(--tg-theme-button-color, #007AFF);
    color: var(--tg-theme-button-text-color, white);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.notebook-tab:hover:not(.active) {
    background: var(--tg-theme-bg-color, rgba(255, 255, 255, 0.5));
}

.notebook-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.notebook-add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.notebook-add-btn:active {
    transform: translateY(0);
}

.notebook-entries {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notebook-entry {
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

.notebook-entry:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.notebook-entry:active {
    transform: translateY(0);
}

.notebook-entry-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.notebook-entry-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
    flex: 1;
    margin: 0;
}

.notebook-entry-type {
    font-size: 20px;
    flex-shrink: 0;
}

.notebook-entry-type.note {
    color: #3b82f6;
}

.notebook-entry-type.task {
    color: #f59e0b;
}

.notebook-entry-content {
    font-size: 14px;
    color: var(--tg-theme-hint-color, #666);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.notebook-entry-footer {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    gap: 8px;
    flex-wrap: wrap;
}

.notebook-entry-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.notebook-entry-priority {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 500;
}

.notebook-entry-priority.low {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.notebook-entry-priority.medium {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

.notebook-entry-priority.high {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.notebook-entry-priority.urgent {
    background: #dc2626;
    color: white;
}

.notebook-entry-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 500;
}

.notebook-entry-status.open {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
}

.notebook-entry-status.in_progress {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

.notebook-entry-status.completed {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.notebook-entry-status.cancelled {
    background: rgba(107, 114, 128, 0.15);
    color: #6b7280;
}

.notebook-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--tg-theme-hint-color, #666);
}

.notebook-empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.6;
}

.notebook-empty-text {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--tg-theme-text-color, #1a1a1a);
}

.notebook-empty-hint {
    font-size: 14px;
    color: var(--tg-theme-hint-color, #999);
}

.notebook-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.notebook-modal-content {
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.notebook-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.notebook-modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
    margin: 0;
}

.notebook-modal-close {
    width: 32px;
    height: 32px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    color: var(--tg-theme-hint-color, #666);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.notebook-modal-close:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
}

.notebook-form-group {
    margin-bottom: 20px;
}

.notebook-form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--tg-theme-text-color, #1a1a1a);
}

.notebook-form-input,
.notebook-form-textarea,
.notebook-form-select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
    border-radius: 12px;
    font-size: 15px;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color, #1a1a1a);
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.notebook-form-input:focus,
.notebook-form-textarea:focus,
.notebook-form-select:focus {
    outline: none;
    border-color: var(--tg-theme-button-color, #007AFF);
}

.notebook-form-textarea {
    min-height: 120px;
    resize: vertical;
}

.notebook-form-row {
    display: flex;
    gap: 12px;
}

.notebook-form-row .notebook-form-group {
    flex: 1;
}

.notebook-form-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

.notebook-btn {
    flex: 1;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.notebook-btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.notebook-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.notebook-btn-secondary {
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    color: var(--tg-theme-text-color, #1a1a1a);
    border: none;
}

.notebook-btn-secondary:hover {
    background: var(--tg-theme-secondary-bg-color, #e5e5e5);
}

.notebook-ai-panel {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    color: white;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.notebook-ai-panel-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notebook-ai-panel-description {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 16px;
    line-height: 1.5;
}

.notebook-ai-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.notebook-ai-btn {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.notebook-ai-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.notebook-subtasks {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
}

.notebook-subtask {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.03));
    border-radius: 12px;
    margin-bottom: 10px;
}

.notebook-subtask-checkbox {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: var(--tg-theme-button-color, #007AFF);
}

.notebook-subtask-title {
    flex: 1;
    font-size: 14px;
    color: var(--tg-theme-text-color, #1a1a1a);
}

.notebook-subtask-time {
    font-size: 12px;
    color: var(--tg-theme-hint-color, #666);
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
}

.notebook-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    gap: 16px;
    color: var(--tg-theme-hint-color, #666);
}

.notebook-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
    border-top-color: var(--tg-theme-button-color, #007AFF);
    border-radius: 50%;
    animation: notebook-spin 0.8s linear infinite;
}

@keyframes notebook-spin {
    to { transform: rotate(360deg); }
}

.notebook-estimate-card {
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-top: 20px;
    border: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

.notebook-estimate-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.notebook-estimate-time {
    font-size: 28px;
    font-weight: 700;
    color: var(--tg-theme-button-color, #007AFF);
}

.notebook-estimate-label {
    font-size: 14px;
    color: var(--tg-theme-hint-color, #666);
}

.notebook-estimate-details {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.notebook-estimate-detail {
    font-size: 14px;
    color: var(--tg-theme-hint-color, #666);
}

.notebook-estimate-detail span {
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
}

/* ==================== SPACES SYSTEM ==================== */

.notebook-spaces-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    padding-top: 60px;
}

.notebook-spaces-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px 20px;
}

.notebook-spaces-empty-icon {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.notebook-spaces-empty-icon span {
    font-size: 56px;
}

.notebook-spaces-empty-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
    margin-bottom: 12px;
}

.notebook-spaces-empty-subtitle {
    font-size: 15px;
    color: var(--tg-theme-hint-color, #666);
    margin-bottom: 32px;
    max-width: 280px;
    line-height: 1.5;
}

.notebook-create-space-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 18px 32px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
    width: 100%;
    max-width: 280px;
    margin-bottom: 16px;
}

.notebook-create-space-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45);
}

.notebook-import-space-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    color: var(--tg-theme-text-color, #1a1a1a);
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 280px;
}

.notebook-import-space-btn:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
}

/* Spaces List */
.notebook-spaces-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notebook-space-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.notebook-space-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.notebook-space-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

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

.notebook-space-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notebook-space-meta {
    font-size: 13px;
    color: var(--tg-theme-hint-color, #666);
}

.notebook-space-arrow {
    font-size: 20px;
    color: var(--tg-theme-hint-color, #999);
}

/* Space Editor */
.notebook-space-editor {
    display: flex;
    flex-direction: column;
    
}

.notebook-space-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

.notebook-space-back-btn {
    width: 40px;
    height: 40px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.notebook-space-back-btn:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
}

.notebook-space-header-info {
    flex: 1;
    min-width: 0;
}

.notebook-space-header-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notebook-space-header-title input {
    background: transparent;
    border: none;
    font-size: 18px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 6px;
    width: 100%;
}

.notebook-space-header-title input:focus {
    outline: none;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

.notebook-space-actions {
    display: flex;
    gap: 8px;
}

.notebook-space-action-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.notebook-space-action-btn:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

/* Blocks */
.notebook-blocks-container {
    
    
    padding-bottom: 80px;
}

.notebook-block {
    position: relative;
    margin-bottom: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.notebook-block:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.02));
}

.notebook-block-content {
    padding: 0 12px;
    min-height: 24px;
    outline: none;
    font-size: 15px;
    line-height: 24px;
    color: var(--tg-theme-text-color, #1a1a1a);
}

.notebook-block-content:empty:before {
    content: attr(data-placeholder);
    color: var(--tg-theme-hint-color, #999);
}

.notebook-block-content.heading {
    font-size: 20px;
    font-weight: 600;
    padding: 12px 12px;
}

.notebook-block-subspace-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.08) 100%);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 8px 0;
}

.notebook-block-subspace-link:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    transform: translateX(4px);
}

.notebook-block-subspace-link .icon {
    font-size: 20px;
}

.notebook-block-subspace-link .title {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: var(--tg-theme-text-color, #1a1a1a);
}

.notebook-block-subspace-link .arrow {
    color: var(--tg-theme-hint-color, #999);
}

/* Add Block Button */
.notebook-add-block-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: 2px dashed var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
    border-radius: 10px;
    color: var(--tg-theme-hint-color, #666);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-top: 12px;
}

.notebook-add-block-btn:hover {
    border-color: var(--tg-theme-button-color, #6366f1);
    color: var(--tg-theme-button-color, #6366f1);
    background: rgba(99, 102, 241, 0.05);
}

/* Selection Menu */
.notebook-selection-menu {
    position: fixed;
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px;
    z-index: 1000;
    display: none;
}

.notebook-selection-menu.visible {
    display: flex;
    gap: 4px;
}

.notebook-selection-menu-btn {
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--tg-theme-text-color, #1a1a1a);
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.notebook-selection-menu-btn:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

.notebook-selection-menu-btn.primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

/* Breadcrumbs */
.notebook-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--tg-theme-hint-color, #666);
    margin-top: 4px;
    flex-wrap: wrap;
}

.notebook-breadcrumb {
    cursor: pointer;
    transition: color 0.2s;
}

.notebook-breadcrumb:hover {
    color: var(--tg-theme-button-color, #6366f1);
}

.notebook-breadcrumb-separator {
    opacity: 0.5;
}

/* ==================== SPACE COVERS ==================== */
.notebook-space-cover {
    height: 120px;
    border-radius: 16px 16px 0 0;
    position: relative;
    overflow: hidden;
    margin: -16px -16px 16px -16px;
}

.notebook-space-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.8;
}

/* Predefined beautiful covers */
.cover-aurora {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

.cover-sunset {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.cover-ocean {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.cover-forest {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.cover-night {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
}

.cover-peach {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.cover-lavender {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
}

.cover-mint {
    background: linear-gradient(135deg, #d4fc79 0%, #96e6a1 100%);
}

.cover-coral {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.cover-cosmic {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 30%, #0f3460 60%, #e94560 100%);
}

.cover-mesh-1 {
    background: 
        radial-gradient(at 40% 20%, hsla(28,100%,74%,1) 0px, transparent 50%),
        radial-gradient(at 80% 0%, hsla(189,100%,56%,1) 0px, transparent 50%),
        radial-gradient(at 0% 50%, hsla(355,100%,93%,1) 0px, transparent 50%),
        radial-gradient(at 80% 50%, hsla(340,100%,76%,1) 0px, transparent 50%),
        radial-gradient(at 0% 100%, hsla(22,100%,77%,1) 0px, transparent 50%),
        radial-gradient(at 80% 100%, hsla(242,100%,70%,1) 0px, transparent 50%),
        radial-gradient(at 0% 0%, hsla(343,100%,76%,1) 0px, transparent 50%);
    background-color: #fff;
}

.cover-mesh-2 {
    background: 
        radial-gradient(at 0% 0%, hsla(253,73%,64%,1) 0px, transparent 50%),
        radial-gradient(at 100% 0%, hsla(225,73%,57%,1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, hsla(339,91%,65%,1) 0px, transparent 50%),
        radial-gradient(at 0% 100%, hsla(189,100%,56%,1) 0px, transparent 50%);
    background-color: #1a1a2e;
}

.cover-abstract {
    background: linear-gradient(60deg, #3d3393 0%, #2b76b9 37%, #2cacd1 65%, #35eb93 100%);
}

.cover-change-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.notebook-space-cover:hover .cover-change-btn {
    opacity: 1;
}

/* ==================== EMOJI & COVER PICKER ==================== */
.picker-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.picker-content {
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 20px;
    width: 100%;
    max-width: 340px;
    max-height: 70vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.picker-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.picker-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
    margin: 0;
}

.picker-close {
    width: 28px;
    height: 28px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.picker-body {
    padding: 16px;
    overflow-y: auto;
    max-height: calc(70vh - 60px);
}

/* Emoji Grid */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.emoji-item {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    background: transparent;
    border: none;
}

.emoji-item:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    transform: scale(1.1);
}

.emoji-item.selected {
    background: var(--tg-theme-button-color, #6366f1);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Cover Grid */
.cover-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.cover-item {
    height: 60px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 3px solid transparent;
    position: relative;
}

.cover-item:hover {
    transform: scale(1.05);
}

.cover-item.selected {
    border-color: var(--tg-theme-button-color, #6366f1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.cover-item.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--tg-theme-button-color, #6366f1);
    font-weight: bold;
}

.picker-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--tg-theme-hint-color, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 0 10px 0;
}

.picker-section-title:first-child {
    margin-top: 0;
}

/* ==================== BLOCK DRAG & DROP ==================== */
.notebook-block {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.notebook-block-drag-handle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
    align-self: center;
    border-radius: 4px;
    color: var(--tg-theme-hint-color, #999);
}

.notebook-block:hover .notebook-block-drag-handle {
    opacity: 1;
}

.notebook-block-drag-handle:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

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

.drag-handle-icon {
    width: 16px;
    height: 16px;
    opacity: 0.6;
    pointer-events: none;
}

.notebook-block-drag-handle:hover .drag-handle-icon {
    opacity: 1;
}

@media (prefers-color-scheme: dark) {
    .drag-handle-icon {
        filter: invert(1);
    }
}

.notebook-block.dragging {
    opacity: 0.5;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

.notebook-block.drag-over {
    border-top: 2px solid var(--tg-theme-button-color, #6366f1);
}

.notebook-block-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

/* ==================== BLOCK CONTEXT MENU ==================== */
.block-context-menu {
    position: fixed;
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    min-width: 200px;
    max-width: 260px;
    animation: contextMenuFadeIn 0.15s ease;
    overflow: hidden;
}

.block-context-menu-container {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.block-context-menu-level {
    width: 100%;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--tg-theme-hint-color, #999) transparent;
}

.block-context-menu-level::-webkit-scrollbar {
    width: 4px;
}

.block-context-menu-level::-webkit-scrollbar-track {
    background: transparent;
}

.block-context-menu-level::-webkit-scrollbar-thumb {
    background: var(--tg-theme-hint-color, #999);
    border-radius: 2px;
}

.block-context-menu-level.hidden {
    display: none;
}

.block-context-menu-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.03));
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--tg-theme-button-color, #6366f1);
    width: 100%;
    text-align: left;
    transition: background 0.15s;
    border-bottom: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
}

.block-context-menu-back:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.06));
}

.block-context-menu-back-icon {
    font-size: 16px;
}

.block-context-menu-sublevel-title {
    padding: 10px 14px 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tg-theme-hint-color, #999);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes contextMenuSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes contextMenuSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

.block-context-menu-level.slide-in {
    animation: contextMenuSlideIn 0.2s ease forwards;
}

.block-context-menu-level.slide-out {
    animation: contextMenuSlideOut 0.2s ease forwards;
}

.block-context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--tg-theme-text-color, #1a1a1a);
    transition: background 0.15s;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.block-context-menu-item:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

.block-context-menu-item.has-submenu {
    justify-content: space-between;
}

.block-context-menu-item .submenu-arrow {
    opacity: 0.5;
    font-size: 14px;
}

.block-context-menu-item.danger {
    color: #ef4444;
}

.block-context-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.block-context-menu-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.block-context-menu-icon-svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.8;
    filter: var(--icon-filter, none);
}

.block-context-menu-item:hover .block-context-menu-icon-svg {
    opacity: 1;
}

.block-context-menu-item.danger .block-context-menu-icon-svg {
    filter: invert(27%) sepia(92%) saturate(6236%) hue-rotate(355deg) brightness(103%) contrast(106%);
}

@media (prefers-color-scheme: dark) {
    .block-context-menu-icon-svg {
        filter: invert(1);
    }
    .block-context-menu-item.danger .block-context-menu-icon-svg {
        filter: invert(27%) sepia(92%) saturate(6236%) hue-rotate(355deg) brightness(103%) contrast(106%);
    }
}

.block-context-menu-divider {
    height: 1px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
    margin: 6px 0;
}

.block-context-menu-item-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.block-context-submenu {
    position: relative;
}

.block-context-submenu-items {
    position: absolute;
    left: 100%;
    top: 0;
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    padding: 6px;
    min-width: 140px;
    display: none;
}

.block-context-submenu:hover .block-context-submenu-items {
    display: block;
}

/* Block type indicator */
.notebook-block-type-indicator {
    position: absolute;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--tg-theme-hint-color, #999);
    opacity: 0;
    transition: opacity 0.15s;
}

.notebook-block:hover .notebook-block-type-indicator {
    opacity: 0.6;
}

/* Keyboard hints */
.notebook-keyboard-hint {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.notebook-keyboard-hint.visible {
    opacity: 1;
}

/* ==================== BLOCK TYPE STYLES ==================== */

/* Заголовки - класс heading_X на родительском .notebook-block */
.notebook-block.heading_1 .notebook-block-content {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1;
    padding-top: 0;
    padding-bottom: 0;
}

.notebook-block.heading_2 .notebook-block-content {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1;
    padding-top: 0;
    padding-bottom: 0;
}

.notebook-block.heading_3 .notebook-block-content {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1;
    padding-top: 0;
    padding-bottom: 0;
}

/* Выравнивание drag handle для заголовков */
.notebook-block.heading_1 .notebook-block-drag-handle,
.notebook-block.heading_2 .notebook-block-drag-handle,
.notebook-block.heading_3 .notebook-block-drag-handle {
    margin-top: 0;
    align-self: center;
}

.notebook-block.heading_1,
.notebook-block.heading_2,
.notebook-block.heading_3 {
    align-items: center;
}

/* Списки */
.notebook-block.bullet_list .notebook-block-bullet,
.notebook-block.numbered_list .notebook-block-number {
    flex-shrink: 0;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 0;
    color: var(--tg-theme-text-color, #1a1a1a);
}

.notebook-block.bullet_list .notebook-block-bullet::before {
    content: "•";
    font-size: 20px;
    line-height: 1;
}

/* TODO блоки */
.notebook-block.todo .notebook-block-checkbox {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    border: 2px solid var(--tg-theme-hint-color, #999);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.notebook-block.todo .notebook-block-checkbox:hover {
    border-color: var(--tg-theme-button-color, #6366f1);
}

.notebook-block.todo .notebook-block-checkbox.checked {
    background: var(--tg-theme-button-color, #6366f1);
    border-color: var(--tg-theme-button-color, #6366f1);
}

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

.notebook-block.todo.checked .notebook-block-content {
    text-decoration: line-through;
    opacity: 0.6;
}

/* V2: Стили для блоков с модификатором checkbox (новая система base_type + modifiers) */
.notebook-block.has-modifier-checkbox .notebook-block-checkbox {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    border: 2px solid var(--tg-theme-hint-color, #999);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.notebook-block.has-modifier-checkbox .notebook-block-checkbox:hover {
    border-color: var(--tg-theme-button-color, #6366f1);
}

.notebook-block.has-modifier-checkbox .notebook-block-checkbox.checked {
    background: var(--tg-theme-button-color, #6366f1);
    border-color: var(--tg-theme-button-color, #6366f1);
}

.notebook-block.has-modifier-checkbox .notebook-block-checkbox.checked::after {
    content: "✓";
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.notebook-block.has-modifier-checkbox.checked .notebook-block-content {
    text-decoration: line-through;
    opacity: 0.6;
}

/* V2: Стили для блоков с модификатором bullet */
.notebook-block.has-modifier-bullet .notebook-block-bullet {
    flex-shrink: 0;
    width: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10px;
    color: var(--tg-theme-text-color, #1a1a1a);
    font-size: 20px;
    line-height: 1;
}

/* V2: Стили для блоков с модификатором numbered */
.notebook-block.has-modifier-numbered .notebook-block-number {
    flex-shrink: 0;
    width: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10px;
    color: var(--tg-theme-text-color, #1a1a1a);
}

/* V2: Стили для блоков с модификатором toggle */
.notebook-block.has-modifier-toggle .notebook-block-toggle-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
    color: var(--tg-theme-hint-color, #888);
}

.notebook-block.has-modifier-toggle .notebook-block-toggle-icon::before {
    content: "▶";
    font-size: 10px;
}

.notebook-block.has-modifier-toggle .notebook-block-toggle-icon.expanded::before {
    content: "▼";
}

/* Цитата */
.notebook-block.quote {
    border-left: 3px solid var(--tg-theme-button-color, #6366f1);
    padding-left: 16px;
    margin-left: 4px;
}

.notebook-block.quote .notebook-block-content {
    font-style: italic;
    color: var(--tg-theme-hint-color, #666);
}

/* Разделитель */
.notebook-block.divider {
    padding: 16px 0;
}

.notebook-block.divider .notebook-block-divider-line {
    height: 1px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
    width: 100%;
}

/* Код */
.notebook-block.code .notebook-block-content {
    font-family: 'SF Mono', 'Fira Code', 'Menlo', monospace;
    font-size: 14px;
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    padding: 12px 16px;
    border-radius: 8px;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Вложенность (indent) */
.notebook-block[data-indent="1"] {
    margin-left: 24px;
}

.notebook-block[data-indent="2"] {
    margin-left: 48px;
}

.notebook-block[data-indent="3"] {
    margin-left: 72px;
}

/* ==================== SLASH COMMAND MENU ==================== */
.slash-command-menu {
    position: absolute;
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    padding: 6px;
    z-index: 2000;
    min-width: 220px;
    max-height: 300px;
    overflow-y: auto;
    animation: slashMenuFadeIn 0.15s ease;
}

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

.slash-command-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.slash-command-item:hover,
.slash-command-item.selected {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

.slash-command-item-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.slash-command-item-info {
    flex: 1;
}

.slash-command-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--tg-theme-text-color, #1a1a1a);
}

.slash-command-item-desc {
    font-size: 12px;
    color: var(--tg-theme-hint-color, #999);
}

/* ==================== INLINE FORMATTING TOOLBAR ==================== */
.inline-toolbar {
    position: absolute;
    background: #1a1a1a;
    border-radius: 8px;
    padding: 4px;
    display: flex;
    gap: 2px;
    z-index: 2000;
    animation: toolbarFadeIn 0.1s ease;
}

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

.inline-toolbar-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s;
    border: none;
    background: transparent;
}

.inline-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.inline-toolbar-btn.active {
    background: rgba(255, 255, 255, 0.2);
}

.inline-toolbar-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    margin: 4px 4px;
}

/* ==================== TOGGLE/SLIDER BLOCKS ==================== */
.notebook-block.toggle {
    display: flex;
    align-items: center;
    gap: 4px;
}

.notebook-block-toggle-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    color: var(--tg-theme-hint-color, #666);
    transition: all 0.2s ease;
    border-radius: 4px;
    flex-shrink: 0;
}

.notebook-block-toggle-icon:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    color: var(--tg-theme-text-color, #1a1a1a);
}

.notebook-block.toggle[data-toggle-expanded="true"] .notebook-block-toggle-icon {
    color: var(--tg-theme-button-color, #6366f1);
}

.notebook-block-add-subblock {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: var(--tg-theme-hint-color, #999);
    transition: all 0.2s ease;
    border-radius: 4px;
    opacity: 0;
    
    align-self: center;
    flex-shrink: 0;
}

.notebook-block:hover .notebook-block-add-subblock {
    opacity: 1;
}

.notebook-block-add-subblock:hover {
    background: var(--tg-theme-button-color, #6366f1);
    color: white;
}



/* Lock button for Enter key behavior */
.notebook-block-lock {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--tg-theme-hint-color, #999);
    transition: all 0.2s ease;
    opacity: 0;
    flex-shrink: 0;
    margin-left: 4px;
    align-self: center;
    border-radius: 4px;
}

.notebook-block:hover .notebook-block-lock {
    opacity: 1;
}

.notebook-block-lock:hover {
    color: var(--tg-theme-button-color, #6366f1);
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

.notebook-block-lock.locked {
    color: var(--tg-theme-button-color, #6366f1);
    opacity: 0.7;
}

.notebook-block-lock.locked:hover {
    opacity: 1;
}

.notebook-block-lock svg {
    width: 16px;
    height: 16px;
}

/* Comment button for blocks */
.notebook-block-comment {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--tg-theme-hint-color, #999);
    transition: all 0.2s ease;
    opacity: 0;
    flex-shrink: 0;
    margin-left: 4px;
    align-self: center;
    border-radius: 4px;
}

.notebook-block:hover .notebook-block-comment {
    opacity: 1;
}

.notebook-block-comment:hover {
    color: var(--tg-theme-button-color, #6366f1);
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
}

.notebook-block-comment.has-comment {
    opacity: 1;
}

.notebook-block-comment svg {
    width: 16px;
    height: 16px;
}

/* Color marker for blocks with comments */
.notebook-block-comment-marker {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 0 4px 4px 0;
    opacity: 0.8;
}

.notebook-block-comment-marker.yellow { background: #fbbf24; }
.notebook-block-comment-marker.orange { background: #f97316; }
.notebook-block-comment-marker.red { background: #ef4444; }
.notebook-block-comment-marker.pink { background: #ec4899; }
.notebook-block-comment-marker.purple { background: #a855f7; }
.notebook-block-comment-marker.blue { background: #3b82f6; }
.notebook-block-comment-marker.green { background: #22c55e; }
.notebook-block-comment-marker.gray { background: #6b7280; }

/* Indented blocks (subblocks) */
.notebook-block[data-indent="1"] {
    margin-left: 24px;
    border-left: 2px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
    padding-left: 12px;
}

.notebook-block[data-indent="2"] {
    margin-left: 48px;
    border-left: 2px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
    padding-left: 12px;
}

.notebook-block[data-indent="3"] {
    margin-left: 72px;
    border-left: 2px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
    padding-left: 12px;
}

.notebook-block[data-indent="4"] {
    margin-left: 96px;
    border-left: 2px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
    padding-left: 12px;
}

.notebook-block[data-indent="5"] {
    margin-left: 120px;
    border-left: 2px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
    padding-left: 12px;
}

/* Hover hint for adding subblocks */
.notebook-block:hover::after {
    content: attr(data-hover-hint);
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--tg-theme-hint-color, #999);
    opacity: 0.7;
    pointer-events: none;
}

.notebook-block {
    position: relative;
}

/* Context menu separator */
.block-context-menu-separator {
    height: 1px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
    margin: 4px 8px;
}

/* Toggle children container */
.toggle-children {
    margin-left: 24px;
    padding-left: 12px;
    border-left: 2px solid rgba(99, 102, 241, 0.2);
}

/* Animation for expand/collapse */
.notebook-block.toggle .toggle-children {
    animation: slideDown 0.2s ease;
}

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

/* Improved subblock visual indicator */
.notebook-block[data-indent]:not([data-indent="0"])::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 14px;
    width: 8px;
    height: 2px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
}

/* Bottom Navigation Panel */
.notebook-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    pointer-events: none;
}

.notebook-bottom-nav-toggle {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 24px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.notebook-bottom-nav-toggle svg {
    width: 16px;
    height: 16px;
    color: var(--tg-theme-hint-color, #999);
    transition: transform 0.3s ease;
}

.notebook-bottom-nav.expanded .notebook-bottom-nav-toggle svg {
    transform: rotate(180deg);
}

.notebook-bottom-nav-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--tg-theme-bg-color, #fff);
    border-top: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
    padding: 12px 20px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    gap: 32px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    pointer-events: auto;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.notebook-bottom-nav.expanded .notebook-bottom-nav-panel {
    transform: translateY(0);
}

.notebook-bottom-nav.expanded .notebook-bottom-nav-toggle {
    bottom: calc(100% + 8px);
}

.notebook-nav-btn {
    width: 48px;
    height: 48px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    border: none;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.notebook-nav-btn:active {
    transform: scale(0.95);
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
}

.notebook-nav-btn svg {
    width: 24px;
    height: 24px;
    color: var(--tg-theme-text-color, #333);
}

/* Hide old back button in header */
.notebook-space-back-btn {
    display: none;
}

/* Remove bottom padding restriction */
.notebook-blocks-container {
    padding-bottom: 80px;
}

/* ==================== BLOCK MOVE CONFIRM DIALOG ==================== */
.notebook-confirm-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.notebook-confirm-dialog {
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 20px;
    padding: 28px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notebook-confirm-dialog-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.notebook-confirm-dialog-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
    margin: 0 0 12px 0;
}

.notebook-confirm-dialog-text {
    font-size: 14px;
    color: var(--tg-theme-hint-color, #666);
    line-height: 1.5;
    margin: 0 0 24px 0;
}

.notebook-confirm-dialog-text strong {
    color: var(--tg-theme-text-color, #1a1a1a);
}

.notebook-confirm-dialog-actions {
    display: flex;
    gap: 12px;
}

.notebook-confirm-dialog-btn {
    flex: 1;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.notebook-confirm-dialog-btn.primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.notebook-confirm-dialog-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.notebook-confirm-dialog-btn.secondary {
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    color: var(--tg-theme-text-color, #1a1a1a);
}

.notebook-confirm-dialog-btn.secondary:hover {
    background: var(--tg-theme-secondary-bg-color, #e5e5e5);
}

/* Parent-child connection line indicator */
.notebook-block[data-indent] {
    position: relative;
}

.notebook-block[data-indent]::before {
    content: '';
    position: absolute;
    left: calc(var(--indent-level, 0) * 24px - 12px);
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.3) 0%, rgba(139, 92, 246, 0.3) 100%);
    border-radius: 1px;
}

.notebook-block[data-indent="1"] { --indent-level: 1; }
.notebook-block[data-indent="2"] { --indent-level: 2; }
.notebook-block[data-indent="3"] { --indent-level: 3; }
.notebook-block[data-indent="4"] { --indent-level: 4; }
.notebook-block[data-indent="5"] { --indent-level: 5; }

.notebook-block.dragging {
    opacity: 0.5;
    background: rgba(99, 102, 241, 0.1);
}

.notebook-block.drag-over {
    border: 2px dashed var(--tg-theme-button-color, #6366f1);
    background: rgba(99, 102, 241, 0.05);
}

/* Toggle Subtype Styles */

/* Headings in toggle - center toggle icon vertically */
.notebook-block.toggle[data-toggle-subtype="heading_1"],
.notebook-block.toggle[data-toggle-subtype="heading_2"],
.notebook-block.toggle[data-toggle-subtype="heading_3"] {
    align-items: center;
}

.notebook-block.toggle[data-toggle-subtype="heading_1"] .notebook-block-toggle-icon,
.notebook-block.toggle[data-toggle-subtype="heading_2"] .notebook-block-toggle-icon,
.notebook-block.toggle[data-toggle-subtype="heading_3"] .notebook-block-toggle-icon {
    margin-top: 0;
}

.notebook-block-content.toggle-subtype-heading_1 {
    font-size: 1.8em;
    font-weight: 700;
    line-height: 1.3;
}

.notebook-block-content.toggle-subtype-heading_2 {
    font-size: 1.5em;
    font-weight: 600;
    line-height: 1.4;
}

.notebook-block-content.toggle-subtype-heading_3 {
    font-size: 1.25em;
    font-weight: 600;
    line-height: 1.4;
}

/* Todo in toggle - use real checkbox element (same as regular todo block) */
.notebook-block.toggle[data-toggle-subtype="todo"] .notebook-block-checkbox {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    border: 2px solid var(--tg-theme-hint-color, #999);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.notebook-block.toggle[data-toggle-subtype="todo"] .notebook-block-checkbox:hover {
    border-color: var(--tg-theme-button-color, #6366f1);
}

.notebook-block.toggle[data-toggle-subtype="todo"] .notebook-block-checkbox.checked {
    background: var(--tg-theme-button-color, #6366f1);
    border-color: var(--tg-theme-button-color, #6366f1);
}

.notebook-block.toggle[data-toggle-subtype="todo"] .notebook-block-checkbox.checked::after {
    content: "✓";
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.notebook-block.toggle[data-toggle-subtype="todo"].checked .notebook-block-content {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Bullet list in toggle - use real bullet element */
.notebook-block.toggle[data-toggle-subtype="bullet_list"] .notebook-block-bullet {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    margin-top: 10px;
}

.notebook-block.toggle[data-toggle-subtype="bullet_list"] .notebook-block-bullet::before {
    content: "•";
    font-size: 20px;
    line-height: 1;
    color: var(--tg-theme-text-color, #333);
}

/* Numbered list in toggle - use real number element */
.notebook-block.toggle[data-toggle-subtype="numbered_list"] .notebook-block-number {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-right: 8px;
    margin-top: 10px;
    font-size: 14px;
    color: var(--tg-theme-text-color, #333);
}

/* Context menu active item */
.block-context-menu-item.active {
    background: var(--tg-theme-button-color, #007AFF);
    color: var(--tg-theme-button-text-color, white);
}

.block-context-menu-item.active .block-context-menu-icon-svg {
    filter: brightness(0) invert(1);
}

/* Comment Modal */
.notebook-comment-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.notebook-comment-modal-content {
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.notebook-comment-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.notebook-comment-modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
    margin: 0;
}

/* Comment color picker */
.notebook-comment-colors {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.notebook-comment-color {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 3px solid transparent;
}

.notebook-comment-color:hover {
    transform: scale(1.1);
}

.notebook-comment-color.selected {
    border-color: var(--tg-theme-text-color, #1a1a1a);
    transform: scale(1.15);
}

.notebook-comment-color.yellow { background: #fbbf24; }
.notebook-comment-color.orange { background: #f97316; }
.notebook-comment-color.red { background: #ef4444; }
.notebook-comment-color.pink { background: #ec4899; }
.notebook-comment-color.purple { background: #a855f7; }
.notebook-comment-color.blue { background: #3b82f6; }
.notebook-comment-color.green { background: #22c55e; }
.notebook-comment-color.gray { background: #6b7280; }
/* Block Actions Container - Responsive */
.notebook-block-actions-container {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    z-index: 10;
    
    margin-right: 4px;
}

.notebook-block-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.25s ease;
}

.notebook-block-actions-toggle {
    display: none;
    width: 24px;
    height: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--tg-theme-hint-color, #999);
    border-radius: 6px;
    flex-shrink: 0;
}

.notebook-block-actions-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.25s ease;
}

.notebook-block-actions-toggle:active {
    background: var(--tg-theme-secondary-bg-color, #f0f0f0);
    color: var(--tg-theme-text-color, #333);
}

.notebook-block-actions-container.expanded .notebook-block-actions-toggle svg {
    transform: rotate(180deg);
}

/* Mobile responsive - hide actions, show toggle */
@media (max-width: 480px) {
    .notebook-block-actions-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .notebook-block-actions {
        overflow: hidden;
        max-width: 0;
        opacity: 0;
        pointer-events: none;
    }
    
    .notebook-block-actions-container.expanded .notebook-block-actions {
        max-width: 150px;
        opacity: 1;
        pointer-events: auto;
    }
    
    /* Text adapts when actions expand */
    .notebook-block-content,
    .notebook-block-wrapper {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Desktop - always show actions on hover, hide toggle */
@media (min-width: 481px) {
    .notebook-block-actions-toggle {
        display: none !important;
    }
    
    .notebook-block-actions {
        opacity: 0;
        transition: opacity 0.2s ease;
    }
    
    .notebook-block:hover .notebook-block-actions {
        opacity: 1;
    }
}

/* ==================== MULTI-COLUMN GRID LAYOUT ==================== */

.notebook-block-row {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    transition: background 0.2s ease;
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    box-sizing: border-box;
}

.notebook-block-row::-webkit-scrollbar {
    height: 6px;
}

.notebook-block-row::-webkit-scrollbar-track {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    border-radius: 3px;
}

.notebook-block-row::-webkit-scrollbar-thumb {
    background: var(--tg-theme-hint-color, #999);
    border-radius: 3px;
}

.notebook-block-row::-webkit-scrollbar-thumb:hover {
    background: var(--tg-theme-button-color, #6366f1);
}

.notebook-block-row:hover {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.02));
}

.notebook-block-row.dragging-over {
    background: rgba(99, 102, 241, 0.08);
    border: 2px dashed var(--tg-theme-button-color, #6366f1);
}

.notebook-block-column {
    flex: 1;
    min-width: 240px;
    max-width: 100%;
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
    position: relative;
    overflow: visible;
}

.notebook-block-column:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.notebook-block-column.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.notebook-block-column.drop-target {
    border: 2px solid var(--tg-theme-button-color, #6366f1);
    background: rgba(99, 102, 241, 0.05);
}

.notebook-block-column .notebook-block {
    margin-bottom: 0;
    position: relative;
    overflow: visible;
}

/* Column drop zones */
.column-drop-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.column-drop-zone.left {
    left: -10px;
}

.column-drop-zone.right {
    right: -10px;
}

.column-drop-zone.active {
    opacity: 1;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.3) 0%, transparent 100%);
}

.column-drop-zone.right.active {
    background: linear-gradient(270deg, rgba(99, 102, 241, 0.3) 0%, transparent 100%);
}

/* Row drop zone for adding new rows in table */
.row-drop-zone {
    position: relative;
    height: 40px;
    margin: 8px 0;
    border: 2px dashed var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tg-theme-hint-color, #666);
    font-size: 13px;
    opacity: 0;
    transition: all 0.2s ease;
    cursor: pointer;
}

.row-drop-zone.visible {
    opacity: 1;
}

.row-drop-zone:hover {
    border-color: var(--tg-theme-button-color, #6366f1);
    color: var(--tg-theme-button-color, #6366f1);
    background: rgba(99, 102, 241, 0.05);
}

.row-drop-zone.drop-target {
    border-color: var(--tg-theme-button-color, #6366f1);
    background: rgba(99, 102, 241, 0.1);
}

.row-drop-zone-icon {
    font-size: 18px;
    margin-right: 6px;
}

/* Add column button - hidden by default, shown on row hover/focus */
.add-column-btn {
    min-width: 40px;
    max-width: 40px;
    height: 100%;
    min-height: 60px;
    background: transparent;
    border: 2px dashed var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.1));
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tg-theme-hint-color, #666);
    font-size: 20px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    opacity: 0;
    pointer-events: none;
}

/* Show add column button when row is hovered or focused */
.notebook-block-row:hover .add-column-btn,
.notebook-block-row:focus-within .add-column-btn,
.notebook-block-row.active .add-column-btn {
    opacity: 1;
    pointer-events: auto;
}

.add-column-btn:hover {
    border-color: var(--tg-theme-button-color, #6366f1);
    color: var(--tg-theme-button-color, #6366f1);
    background: rgba(99, 102, 241, 0.05);
}

/* Column resize handle */
.column-resize-handle {
    position: absolute;
    top: 0;
    right: -4px;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    background: transparent;
    transition: background 0.2s ease;
    z-index: 5;
}

.column-resize-handle:hover,
.column-resize-handle.resizing {
    background: var(--tg-theme-button-color, #6366f1);
    opacity: 0.5;
}

/* Grid layout variations */
.notebook-block-row.columns-2 .notebook-block-column {
    flex: 0 0 calc(50% - 6px);
}

.notebook-block-row.columns-3 .notebook-block-column {
    flex: 0 0 calc(33.333% - 8px);
}

.notebook-block-row.columns-4 .notebook-block-column {
    flex: 0 0 calc(25% - 9px);
}

.notebook-block-row.columns-5 .notebook-block-column {
    flex: 0 0 calc(20% - 10px);
}

/* Drag visual feedback */
.notebook-block.is-dragging {
    opacity: 0.4;
    transform: scale(0.95);
    z-index: 100;
}

.notebook-block.drag-preview {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.9;
    transform: rotate(3deg) scale(1.02);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    background: var(--tg-theme-bg-color, #fff);
    padding: 12px;
    border-radius: 8px;
}

/* Drag handle indicator */
.notebook-block-drag-handle {
    position: absolute;
    left: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.2s ease;
    color: var(--tg-theme-hint-color, #999);
}

.notebook-block:hover .notebook-block-drag-handle {
    opacity: 1;
}

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

.notebook-block-drag-handle svg {
    width: 16px;
    height: 16px;
}

/* Mobile responsive for grid */
@media (max-width: 600px) {
    .notebook-block-row {
        flex-direction: column;
        overflow-x: visible;
    }
    
    .notebook-block-column {
        min-width: 100%;
        flex: 1 1 100% !important;
    }
    
    .add-column-btn {
        width: 100%;
        max-width: 100%;
        min-height: 40px;
        height: auto;
    }
    
    .column-drop-zone {
        display: none;
    }
}

/* Horizontal drop zone indicators */
.notebook-block.drag-over-left {
    position: relative;
}

.notebook-block.drag-over-left::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #4a9fff 0%, #2d7fe8 100%);
    border-radius: 2px;
    animation: pulse-indicator 1s ease-in-out infinite;
}

.notebook-block.drag-over-right {
    position: relative;
}

.notebook-block.drag-over-right::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #4a9fff 0%, #2d7fe8 100%);
    border-radius: 2px;
    animation: pulse-indicator 1s ease-in-out infinite;
}

@keyframes pulse-indicator {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== TABLE BLOCK STYLES ==================== */

.notebook-block.table {
    display: flex;
    align-items: flex-start;
    position: relative;
}

.notebook-block-table-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.08) 100%);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.notebook-block-table-header:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(139, 92, 246, 0.12) 100%);
}

.notebook-table-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.notebook-table-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    outline: none;
    border-radius: 6px;
    padding: 2px 6px;
    margin: -2px -6px;
    cursor: text;
    transition: background 0.15s ease;
}

.notebook-table-title:focus {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    white-space: normal;
    overflow: visible;
}

.notebook-table-title:empty:before {
    content: attr(data-placeholder);
    color: var(--tg-theme-hint-color, #999);
    opacity: 0.7;
}

.notebook-table-info {
    font-size: 12px;
    color: var(--tg-theme-hint-color, #666);
    flex-shrink: 0;
}

.notebook-table-toggle {
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    color: var(--tg-theme-hint-color, #666);
    transition: transform 0.2s ease;
}

.notebook-table-container {
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
    background: var(--tg-theme-bg-color, #fff);
}

.notebook-table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--tg-theme-hint-color, #999) transparent;
}

.notebook-table-scroll-wrapper::-webkit-scrollbar {
    height: 6px;
}

.notebook-table-scroll-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.notebook-table-scroll-wrapper::-webkit-scrollbar-thumb {
    background: var(--tg-theme-hint-color, #999);
    border-radius: 3px;
}

.notebook-table {
    width: 100%;
    min-width: 300px;
    border-collapse: collapse;
    table-layout: auto;
}

.notebook-table th,
.notebook-table td {
    border: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
    padding: 0;
    min-width: 100px;
    position: relative;
}

.notebook-table th {
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.03));
    font-weight: 600;
    font-size: 13px;
    color: var(--tg-theme-text-color, #1a1a1a);
}

.notebook-table td {
    background: var(--tg-theme-bg-color, #fff);
}

.notebook-table-cell-content {
    padding: 10px 12px;
    min-height: 20px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--tg-theme-text-color, #1a1a1a);
    outline: none;
    word-break: break-word;
}

.notebook-table-cell-content:empty:before {
    content: '...';
    color: var(--tg-theme-hint-color, #999);
    opacity: 0.5;
}

.notebook-table-cell-content:focus {
    background: rgba(99, 102, 241, 0.05);
}

/* Add column button cell */
.notebook-table-add-col-cell {
    width: 40px;
    min-width: 40px !important;
    max-width: 40px;
    background: transparent !important;
    border: none !important;
    vertical-align: middle;
}

.notebook-table-add-col-btn {
    width: 32px;
    height: 32px;
    border: 2px dashed var(--tg-theme-hint-color, rgba(0, 0, 0, 0.2));
    border-radius: 8px;
    background: transparent;
    color: var(--tg-theme-hint-color, #666);
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin: 4px;
}

.notebook-table-add-col-btn:hover {
    border-color: var(--tg-theme-button-color, #6366f1);
    color: var(--tg-theme-button-color, #6366f1);
    background: rgba(99, 102, 241, 0.1);
}

/* Row actions cell */
.notebook-table-actions-cell {
    width: 36px;
    min-width: 36px !important;
    max-width: 36px;
    background: transparent !important;
    border: none !important;
    vertical-align: middle;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.notebook-table tbody tr:hover .notebook-table-actions-cell {
    opacity: 1;
}

.notebook-table-delete-row-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin: 4px;
}

.notebook-table-delete-row-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ==================== TABLE DRAG & DROP ==================== */

/* Grip cell for row/column handles */
.notebook-table-grip-cell {
    width: 28px;
    min-width: 28px !important;
    max-width: 28px;
    background: transparent !important;
    border: none !important;
    vertical-align: middle;
    padding: 0 !important;
}

/* Column grip handle */
.notebook-table-col-grip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 20px;
    cursor: grab;
    color: var(--tg-theme-hint-color, #999);
    opacity: 0;
    transition: opacity 0.15s ease;
    margin-bottom: 4px;
}

.notebook-table th:hover .notebook-table-col-grip {
    opacity: 1;
}

.notebook-table-col-grip:active {
    cursor: grabbing;
}

.notebook-table-col-grip.dragging {
    opacity: 1;
    color: var(--tg-theme-button-color, #6366f1);
}

/* Row grip handle */
.notebook-table-row-grip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 100%;
    min-height: 36px;
    cursor: grab;
    color: var(--tg-theme-hint-color, #999);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.notebook-table tbody tr:hover .notebook-table-row-grip {
    opacity: 1;
}

.notebook-table-row-grip:active {
    cursor: grabbing;
}

.notebook-table-row-grip.dragging {
    opacity: 1;
    color: var(--tg-theme-button-color, #6366f1);
}

/* Drag markers */
.notebook-table-drop-marker-row {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--tg-theme-button-color, #6366f1);
    border-radius: 2px;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

.notebook-table-drop-marker-col {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--tg-theme-button-color, #6366f1);
    border-radius: 2px;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

/* Dragging row/column visual feedback */
.notebook-table tr.dragging-row {
    opacity: 0.5;
    background: rgba(99, 102, 241, 0.1) !important;
}

.notebook-table th.dragging-col,
.notebook-table td.dragging-col {
    opacity: 0.5;
    background: rgba(99, 102, 241, 0.1) !important;
}

/* Trash zone */
.notebook-table-trash-zone {
    display: none;
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    padding: 16px 32px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 600;
    gap: 10px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(239, 68, 68, 0.4);
    z-index: 2000;
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.notebook-table-trash-zone.visible {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.notebook-table-trash-zone.hover {
    transform: translateX(-50%) scale(1.1);
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 12px 40px rgba(239, 68, 68, 0.6);
}

.notebook-table-trash-zone svg {
    width: 24px;
    height: 24px;
}

/* ==================== TABLE COLUMN RESIZE ==================== */

.notebook-table th {
    position: relative;
}

.notebook-table-resize-handle {
    position: absolute;
    top: 0;
    right: -2px;
    width: 5px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
    transition: background 0.15s ease;
}

.notebook-table-resize-handle:hover,
.notebook-table-resize-handle.resizing {
    background: var(--tg-theme-button-color, #6366f1);
}

.notebook-table-resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 20px;
    background: var(--tg-theme-hint-color, #ccc);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.notebook-table th:hover .notebook-table-resize-handle::after {
    opacity: 1;
}

.notebook-table-resize-handle.resizing::after {
    opacity: 1;
    background: var(--tg-theme-button-color, #6366f1);
}

/* Table with resizing active */
.notebook-table.resizing {
    user-select: none;
    cursor: col-resize;
}

/* Table footer with add row button */
.notebook-table-footer {
    padding: 12px;
    border-top: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
    display: flex;
    gap: 8px;
}

.notebook-table-add-row-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 2px dashed var(--tg-theme-hint-color, rgba(0, 0, 0, 0.15));
    border-radius: 10px;
    background: transparent;
    color: var(--tg-theme-hint-color, #666);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    justify-content: center;
}

.notebook-table-add-row-btn:hover {
    border-color: var(--tg-theme-button-color, #6366f1);
    color: var(--tg-theme-button-color, #6366f1);
    background: rgba(99, 102, 241, 0.05);
}

.notebook-table-add-row-btn span {
    font-size: 16px;
    font-weight: 600;
}

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

@media (max-width: 768px) {
    .notebook-block-table-header {
        padding: 10px 12px;
    }
    
    .notebook-table-title {
        font-size: 14px;
    }
    
    .notebook-table-info {
        font-size: 11px;
    }
    
    .notebook-table th,
    .notebook-table td {
        min-width: 80px;
    }
    
    .notebook-table-cell-content {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    .notebook-table-add-col-cell {
        width: 36px;
        min-width: 36px !important;
        max-width: 36px;
    }
    
    .notebook-table-add-col-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
    
    .notebook-table-footer {
        padding: 10px;
    }
    
    .notebook-table-add-row-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .notebook-section {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    .notebook-spaces-container {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    .notebook-block.table {
        margin-left: -8px;
        margin-right: -8px;
        padding-left: 8px;
        padding-right: 8px;
    }
    
    .notebook-block.table .notebook-block-drag-handle {
        display: none;
    }
    
    .notebook-block.table .notebook-block-toggle-icon {
        position: absolute;
        left: 8px;
        top: 12px;
        z-index: 2;
    }
    
    .notebook-block.table .notebook-block-wrapper {
        width: 100%;
    }
    
    .notebook-block-table-header {
        flex-wrap: nowrap;
        gap: 8px;
        padding-left: 24px;
    }
    
    .notebook-table-info {
        width: auto;
        order: 2;
        text-align: right;
        margin-top: 0;
        cursor: pointer;
        flex-shrink: 0;
    }
    
    .notebook-table-container {
        margin-left: -8px;
        margin-right: -8px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .notebook-table-scroll-wrapper {
        padding: 0;
    }
    
    .notebook-table {
        min-width: 100%;
        width: 100%;
    }
    
    .notebook-table th,
    .notebook-table td {
        min-width: 120px;
    }
    
    .notebook-table-cell-content {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .notebook-table-add-row-btn {
        font-size: 14px;
        width: 100%;
    }
    
    .notebook-table-footer {
        margin-left: -8px;
        margin-right: -8px;
        padding: 12px;
    }
    
    /* Show grip handles on mobile - always visible */
    .notebook-table-grip-cell {
        width: 32px;
        min-width: 32px !important;
        max-width: 32px;
    }
    
    .notebook-table-row-grip,
    .notebook-table-col-grip {
        opacity: 0.6;
    }
    
    /* Make trash zone smaller on mobile */
    .notebook-table-trash-zone {
        bottom: 80px;
        padding: 12px 24px;
        font-size: 14px;
    }
    
    /* Adjust resize handles for touch - wider for easier touch */
    .notebook-table-resize-handle {
        width: 16px;
        right: -8px;
    }
    
    .notebook-table-resize-handle::after {
        opacity: 0.5;
        width: 4px;
        height: 30px;
    }
}

/* Block scrolling during drag/resize */
body.table-dragging,
body.table-resizing {
    overflow: hidden !important;
    touch-action: none !important;
}

body.table-dragging *,
body.table-resizing * {
    user-select: none !important;
}


/* ==================== EMPTY STATE STYLES ==================== */

.notebook-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--tg-theme-hint-color, #666);
}

.notebook-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.notebook-empty-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
    margin-bottom: 8px;
}

.notebook-empty-hint {
    font-size: 14px;
    margin-bottom: 24px;
}

.notebook-empty-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.notebook-empty-add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.notebook-empty-add-btn:active {
    transform: translateY(0);
}

.notebook-empty-add-icon {
    font-size: 20px;
    font-weight: 700;
}

/* ==================== ADD BLOCK MODAL ==================== */

.notebook-add-block-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.notebook-add-block-modal.active {
    opacity: 1;
    visibility: visible;
}

.notebook-add-block-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.notebook-add-block-modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 70vh;
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 20px 20px 0 0;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.notebook-add-block-modal.active .notebook-add-block-modal-content {
    transform: translateY(0);
}

.notebook-add-block-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.08));
}

.notebook-add-block-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #1a1a1a);
}

.notebook-add-block-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.05));
    border-radius: 50%;
    font-size: 20px;
    color: var(--tg-theme-hint-color, #666);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notebook-add-block-modal-body {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-height: calc(70vh - 70px);
    overflow-y: auto;
}

.notebook-add-block-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.03));
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.notebook-add-block-type-btn:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.2);
}

.notebook-add-block-type-btn:active {
    transform: scale(0.95);
}

.notebook-add-block-type-btn img {
    width: 28px;
    height: 28px;
    opacity: 0.8;
}

.notebook-add-block-type-btn span {
    font-size: 12px;
    font-weight: 500;
    color: var(--tg-theme-text-color, #1a1a1a);
    text-align: center;
}

@media (max-width: 480px) {
    .notebook-add-block-modal-body {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 12px;
    }
    
    .notebook-add-block-type-btn {
        padding: 12px 6px;
    }
    
    .notebook-add-block-type-btn img {
        width: 24px;
        height: 24px;
    }
    
    .notebook-add-block-type-btn span {
        font-size: 11px;
    }
}


/* ==================== BLOCK TRASH ZONE (like tables) ==================== */
.notebook-block-trash-zone {
    display: none;
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    padding: 16px 32px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 600;
    gap: 10px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(239, 68, 68, 0.4);
    z-index: 2000;
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.notebook-block-trash-zone.visible {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.notebook-block-trash-zone.hover {
    transform: translateX(-50%) scale(1.1);
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 12px 40px rgba(239, 68, 68, 0.6);
}

.notebook-block-trash-zone svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 600px) {
    .notebook-block-trash-zone {
        bottom: 80px;
        padding: 12px 24px;
        font-size: 14px;
    }
}

/* Move Zone Button - центральная кнопка перемещения */
.notebook-block-move-zone {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.notebook-block-move-zone.visible {
    display: flex;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.notebook-block-move-zone.expanded {
    width: auto;
    min-width: 140px;
    height: auto;
    padding: 16px 24px;
    border-radius: 28px;
    gap: 10px;
}

.notebook-block-move-zone.hover {
    transform: translate(-50%, -50%) scale(1.15);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    box-shadow: 0 16px 48px rgba(102, 126, 234, 0.6);
}

.notebook-block-move-zone svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.notebook-block-move-zone .move-label {
    display: none;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
}

.notebook-block-move-zone.expanded .move-label {
    display: block;
}

/* 3D Card Mode - режим карточек */
.notebook-card-mode {
    perspective: 1200px;
}

.notebook-card-mode .notebook-blocks-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.notebook-card-mode .notebook-block {
    transform-style: preserve-3d;
    transform: rotateX(5deg) translateZ(0);
    transition: transform 0.25s ease-out, box-shadow 0.25s ease-out, opacity 0.2s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    background: var(--tg-theme-bg-color, #fff);
}

.notebook-card-mode .notebook-block:nth-child(odd) {
    transform: rotateX(5deg) rotateY(-2deg) translateZ(0);
}

.notebook-card-mode .notebook-block:nth-child(even) {
    transform: rotateX(5deg) rotateY(2deg) translateZ(0);
}

.notebook-card-mode .notebook-block.card-highlight-above {
    transform: rotateX(5deg) translateZ(20px) translateY(-8px);
    box-shadow: 0 16px 48px rgba(102, 126, 234, 0.3), 0 0 0 3px #667eea;
}

.notebook-card-mode .notebook-block.card-highlight-below {
    transform: rotateX(5deg) translateZ(20px) translateY(8px);
    box-shadow: 0 16px 48px rgba(102, 126, 234, 0.3), 0 0 0 3px #667eea;
}

.notebook-card-mode .notebook-block.card-dragged {
    position: fixed;
    z-index: 2500;
    transform: rotateX(0) rotateY(0) scale(0.95);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
    opacity: 0.95;
    pointer-events: none;
}

/* Placeholder для позиции вставки */
.notebook-card-insert-placeholder {
    height: 8px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    border-radius: 4px;
    margin: 8px 0;
    opacity: 0;
    transform: scaleX(0);
    transition: all 0.2s ease-out;
}

.notebook-card-insert-placeholder.visible {
    opacity: 1;
    transform: scaleX(1);
}

/* Back button - кнопка назад для выхода из режима карточек */
.notebook-card-back-zone {
    display: none;
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    padding: 14px 28px;
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    gap: 8px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(107, 114, 128, 0.4);
    z-index: 2001;
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.notebook-card-back-zone.visible {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.notebook-card-back-zone.hover {
    transform: translateX(-50%) scale(1.08);
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
    box-shadow: 0 10px 32px rgba(107, 114, 128, 0.5);
}

.notebook-card-back-zone svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 600px) {
    .notebook-block-move-zone {
        width: 48px;
        height: 48px;
    }
    
    .notebook-block-move-zone svg {
        width: 24px;
        height: 24px;
    }
    
    .notebook-block-move-zone.expanded {
        min-width: 120px;
        padding: 12px 20px;
    }
    
    .notebook-card-back-zone {
        bottom: 80px;
        padding: 12px 22px;
        font-size: 13px;
    }
}

/* ==================== CARD MODE OVERLAY (3D картотека) ==================== */
.notebook-card-mode-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, 
        rgba(30, 30, 50, 0.97) 0%, 
        rgba(20, 20, 40, 0.98) 100%
    );
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    perspective: 1000px;
}

.notebook-card-mode-overlay.visible {
    opacity: 1;
    transform: scale(1);
}

.card-mode-instruction {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 30px;
    text-align: center;
}

.cards-stack {
    position: relative;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transform-style: preserve-3d;
    max-height: 60vh;
    overflow-y: auto;
    padding: 20px 10px;
}

.card-item {
    background: linear-gradient(145deg, #ffffff 0%, #f0f0f5 100%);
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.15),
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease-out;
    transform-style: preserve-3d;
    position: relative;
    border: 2px solid transparent;
}

.card-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 14px 14px 0 0;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.card-item:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 
        0 12px 32px rgba(102, 126, 234, 0.25),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

.card-item.card-highlight {
    border-color: #667eea;
    transform: translateY(-8px) scale(1.04);
    box-shadow: 
        0 16px 40px rgba(102, 126, 234, 0.35),
        0 0 0 4px rgba(102, 126, 234, 0.2);
}

.card-item.card-highlight::before {
    opacity: 1;
}

.card-item.card-dragged {
    opacity: 0.5;
    transform: scale(0.95);
    cursor: default;
    pointer-events: none;
}

.card-content {
    display: flex;
    align-items: center;
    gap: 14px;
}

.card-index {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.card-text {
    flex: 1;
    font-size: 14px;
    color: #1a1a2e;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Card mode back zone override */
.notebook-card-mode-overlay ~ .notebook-card-back-zone {
    z-index: 3001;
}

@media (max-width: 600px) {
    .cards-stack {
        max-width: 100%;
        padding: 10px;
    }
    
    .card-item {
        padding: 14px 16px;
    }
    
    .card-index {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .card-text {
        font-size: 13px;
    }
}
