* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

.embed-body {
    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 14px;
    line-height: 1.5;
    color: rgb(55, 53, 47);
    background: transparent;
    height: 100%;
    overflow: hidden;
}

.embed-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: transparent;
    padding: 8px;
}

/* Search Container */
/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 4px;
    border-bottom: 1px solid rgba(227, 226, 224, 0.5);
    background: rgba(242, 241, 238, 0.3);
    border-radius: 6px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.search-container {
    display: flex;
    align-items: center;
    background: rgba(242, 241, 238, 0.6);
    border-radius: 4px;
    border: 1px solid rgba(227, 226, 224, 0.5);
    transition: all 0.15s ease;
    margin-right: 8px;
}

.search-container:hover {
    background: rgba(242, 241, 238, 0.8);
}

.search-input {
    border: none;
    background: transparent;
    font-size: 12px;
    color: rgb(55, 53, 47);
    outline: none;
    padding: 4px 6px;
    font-family: inherit;
    width: 200px;
}

.search-input::placeholder {
    color: rgba(55, 53, 47, 0.5);
}

.search-toggle {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.search-toggle:hover {
    background: rgba(55, 53, 47, 0.08);
}

.toolbar-button {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    color: rgba(55, 53, 47, 0.6);
    min-width: 36px;
    height: 36px;
}

.toolbar-button svg {
    width: 16px;
    height: 16px;
    color: rgba(55, 53, 47, 0.6);
}

.toolbar-button:hover {
    background: rgba(55, 53, 47, 0.08);
    color: rgba(55, 53, 47, 0.8);
}

.toolbar-button:hover svg {
    color: rgba(55, 53, 47, 0.8);
}

.toolbar-button:active {
    background: rgba(55, 53, 47, 0.12);
}

.toolbar-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.toolbar-button:disabled:hover {
    background: none;
    color: rgba(55, 53, 47, 0.6);
}

.toolbar-button:disabled svg {
    color: rgba(55, 53, 47, 0.3);
}

.toolbar-button.refreshing {
    animation: spin 1s linear infinite;
}

/* Lock button specific styles */
.lock-button.locked {
    color: rgb(193, 76, 76);
}

.lock-button.locked:hover {
    background: rgba(235, 87, 87, 0.1);
    color: rgb(193, 76, 76);
}

.lock-button.unlocked {
    color: rgb(46, 170, 220);
}

.lock-button.unlocked:hover {
    background: rgba(46, 170, 220, 0.1);
    color: rgb(46, 170, 220);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    justify-content: center;
    color: rgba(55, 53, 47, 0.6);
    font-size: 13px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(55, 53, 47, 0.1);
    border-top: 2px solid rgba(55, 53, 47, 0.4);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Message */
.error-message {
    padding: 12px;
    background: rgba(235, 87, 87, 0.1);
    border: 1px solid rgba(235, 87, 87, 0.2);
    border-radius: 6px;
    color: rgb(193, 76, 76);
    font-size: 13px;
    margin-bottom: 12px;
}

/* Tree Container */
.tree-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.tree {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 120px;
}

/* Tree Nodes */
.tree-node {
    margin: 1px 0;
}

.tree-node-content {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    min-height: 24px;
    font-size: 13px;
}

.tree-node-content:hover {
    background: rgba(55, 53, 47, 0.06);
}

.tree-node-content.highlighted {
    background: rgba(255, 212, 0, 0.14);
    border-left: 2px solid rgb(255, 212, 0);
    padding-left: 4px;
}

.tree-node-content.filtered-out {
    opacity: 0.3;
    pointer-events: none;
}

.tree-toggle {
    width: 16px;
    height: 16px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: rgba(55, 53, 47, 0.5);
    padding: 0;
    border-radius: 2px;
    transition: all 0.15s ease;
}

.tree-toggle svg {
    width: 12px;
    height: 12px;
    color: rgba(55, 53, 47, 0.5);
}

.tree-toggle:hover {
    background: rgba(55, 53, 47, 0.08);
    color: rgba(55, 53, 47, 0.8);
}

.tree-toggle.empty {
    cursor: default;
    opacity: 0;
}

.tree-toggle.empty:hover {
    background: none;
}

.tree-node-icon {
    font-size: 14px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tree-node-icon svg {
    color: rgba(55, 53, 47, 0.6);
}

.tree-node-title {
    color: rgb(55, 53, 47);
    font-weight: 400;
    word-break: break-word;
    line-height: 1.3;
}

.tree-node-link {
    text-decoration: none;
    color: inherit;
    transition: color 0.15s ease;
}

.tree-node-link:hover {
    color: rgb(35, 131, 226);
    text-decoration: underline;
}

.tree-node-title.highlighted-text {
    background: rgba(255, 212, 0, 0.3);
    padding: 1px 2px;
    border-radius: 2px;
}

.tree-children {
    margin-left: 16px;
    border-left: 1px solid rgba(55, 53, 47, 0.09);
    padding-left: 8px;
    margin-top: 2px;
}

.tree-node.collapsed .tree-children {
    display: none;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-align: center;
    color: rgba(55, 53, 47, 0.4);
    flex: 1;
    min-height: 0;
}

.empty-state-icon {
    font-size: 24px;
    margin-bottom: 8px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 13px;
    line-height: 1.4;
}

/* Auto-sizing for iframe */
body.compact .embed-container {
    padding: 4px;
}

body.compact .toolbar {
    margin-bottom: 6px;
    padding: 2px;
}

body.compact .search-container {
    padding: 2px 4px;
    margin-right: 4px;
}

body.compact .search-input {
    width: 180px;
    padding: 2px 4px;
    font-size: 11px;
}

body.compact .toolbar-button {
    min-width: 32px;
    height: 32px;
    padding: 6px 8px;
    font-size: 12px;
}

body.compact .tree-node-content {
    padding: 2px 4px;
    min-height: 20px;
    font-size: 12px;
}

body.compact .tree-children {
    margin-left: 12px;
    padding-left: 6px;
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .embed-body {
        color: rgba(255, 255, 255, 0.9);
    }
    
    .search-container {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .search-container:hover {
        background: rgba(255, 255, 255, 0.06);
    }
    
    .search-input {
        color: rgba(255, 255, 255, 0.9);
    }
    
    .search-input::placeholder {
        color: rgba(255, 255, 255, 0.4);
    }
    
    .tree-node-content:hover {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .tree-node-content.highlighted {
        background: rgba(255, 212, 0, 0.2);
    }
    
    .tree-children {
        border-left-color: rgba(255, 255, 255, 0.1);
    }
    
    .tree-toggle {
        color: rgba(255, 255, 255, 0.4);
    }
    
    .tree-toggle svg {
        color: rgba(255, 255, 255, 0.4);
    }
    
    .tree-toggle:hover {
        background: rgba(255, 255, 255, 0.08);
        color: rgba(255, 255, 255, 0.7);
    }
    
    .tree-toggle:hover svg {
        color: rgba(255, 255, 255, 0.7);
    }
    
    .tree-node-icon svg {
        color: rgba(255, 255, 255, 0.6);
    }
    
    .tree-node-title {
        color: rgba(255, 255, 255, 0.9);
    }
    
    .tree-node-link:hover {
        color: rgb(58, 150, 255);
    }
    
    .action-button {
        color: rgba(255, 255, 255, 0.5);
    }
    
    .action-button:hover {
        background: rgba(255, 255, 255, 0.08);
        color: rgba(255, 255, 255, 0.8);
    }
    
    .action-button:active {
        background: rgba(255, 255, 255, 0.12);
    }
}

/* Add Page Button */
/* Tree Footer */
.tree-footer {
    margin-top: 8px;
    border-top: 1px solid rgba(55, 53, 47, 0.1);
    padding-top: 8px;
}

.tree-footer-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid rgba(55, 53, 47, 0.2);
    border-radius: 4px;
    background: rgba(55, 53, 47, 0.05);
    color: rgb(55, 53, 47);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.footer-button:hover {
    background: rgba(55, 53, 47, 0.08);
    border-color: rgba(55, 53, 47, 0.3);
}

.lock-button {
    min-width: 32px;
    justify-content: center;
    padding: 6px 8px;
}

.lock-button.locked {
    background: rgba(235, 87, 87, 0.1);
    border-color: rgba(235, 87, 87, 0.2);
    color: rgb(193, 76, 76);
}

.lock-button.locked:hover {
    background: rgba(235, 87, 87, 0.15);
}

.lock-button.unlocked {
    background: rgba(46, 170, 220, 0.1);
    border-color: rgba(46, 170, 220, 0.2);
    color: rgb(46, 170, 220);
}

.lock-button.unlocked:hover {
    background: rgba(46, 170, 220, 0.15);
}

.add-page-section {
    flex: 1;
    transition: opacity 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.add-page-section.hidden {
    opacity: 0;
    pointer-events: none;
}

.add-icon {
    font-size: 14px;
    font-weight: bold;
}

.add-text {
    font-size: 12px;
}

.add-page-button {
    background: rgba(46, 170, 220, 0.1);
    border-color: rgba(46, 170, 220, 0.2);
    color: rgb(46, 170, 220);
    flex: 1;
}

.add-page-button:hover {
    background: rgba(46, 170, 220, 0.15);
    border-color: rgba(46, 170, 220, 0.3);
}

/* Add Page Modal */
.add-page-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;
    animation: modalFadeIn 0.15s ease;
}

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

.add-page-modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.15s ease;
}

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

.add-page-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(227, 226, 224, 0.5);
}

.add-page-modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: rgb(55, 53, 47);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: rgb(120, 119, 116);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.modal-close:hover {
    background: rgba(55, 53, 47, 0.08);
    color: rgb(55, 53, 47);
}

.add-page-modal-body {
    padding: 20px;
}

.add-page-modal-body label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: rgb(55, 53, 47);
    margin-bottom: 8px;
}

.add-page-modal-body textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(227, 226, 224, 0.5);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.15s ease;
}

.add-page-modal-body textarea:focus {
    outline: none;
    border-color: rgb(46, 170, 220);
    box-shadow: 0 0 0 2px rgba(46, 170, 220, 0.2);
}

.add-page-modal-body textarea::placeholder {
    color: rgb(120, 119, 116);
}

.add-page-modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.modal-button {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.modal-button-secondary {
    background: transparent;
    border: 1px solid rgba(227, 226, 224, 0.5);
    color: rgb(120, 119, 116);
}

.modal-button-secondary:hover {
    background: rgba(55, 53, 47, 0.06);
    color: rgb(55, 53, 47);
}

.modal-button-primary {
    background: rgb(46, 170, 220);
    border: 1px solid rgb(46, 170, 220);
    color: white;
}

.modal-button-primary:hover {
    background: rgb(35, 150, 200);
    border-color: rgb(35, 150, 200);
}

.modal-button-primary:active {
    background: rgb(25, 130, 180);
}

/* Empty state updates */
.empty-state-subtitle {
    font-size: 12px;
    color: rgb(120, 119, 116);
    margin-top: 4px;
}