body {
    background-color: #f0f2f5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.ribbon-menu {
    background-color: #ffffff;
    padding: 0.5rem 1rem;
    flex-shrink: 0;
}

.ribbon-menu .nav-link {
    color: #555;
    position: relative; /* For positioning the dot */
}

.ribbon-menu .nav-link.active {
    background-color: #e7f3ff;
    color: #005a9e;
}

.ribbon-toolbar {
    flex-shrink: 0;
}

main {
    background-color: #f0f2f5;
}

.tab-pane {
    height: 100%;
}

/* Editor Canvas Styles */
#editor-canvas {
    max-width: 800px;
    margin: 0 auto;
    /* Adjust padding to ensure left-side controls are visible on all screen sizes */
}

.editor-element {
    position: relative; /* Essential for positioning of children */
    border: 1px dashed #ccc;
    background-color: #fff;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    transition: box-shadow 0.2s;
}

.editor-element:hover {
    border-color: #0d6efd;
    box-shadow: 0 0 10px rgba(13, 110, 253, 0.2);
}

/* New: Wrapper for internal content and move controls */
.editor-element-inner-content {
    display: flex;
    align-items: flex-start; /* Align items to the top of the flex container */
    gap: 15px; /* Space between move controls and summary content */
}

/* New: Styles for internal move controls */
.element-controls-internal {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background-color: #f8f9fa;
    padding: 5px;
    border-radius: 5px;
    border: 1px solid #dee2e6;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Old .element-controls-top-right, now inside the element */
.element-controls-top-right {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 5px;
}

.element-control-btn {
    width: 30px;
    height: 30px;
    font-size: 14px;
}

/* New: Styles for the preview summary text inside the editor */
.element-preview-summary {
    flex-grow: 1; /* Allow content to take up available space */
    text-align: left; /* Align text within the summary */
}

/* Preview Pane Styles */
#preview-pane {
    background-color: #e9ecef;
    padding-top: 2rem;
    padding-bottom: 2rem;
    overflow-y: auto;
}

.preview-container {
    max-width: 680px;
    width: 100%;
    min-height: 100%;
}

.preview-background {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 100%;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    color: #000;
}

#preview-canvas {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

/* New: Global image size limitation for content within preview-canvas */
#preview-canvas img {
    max-width: 100%;
    height: auto;
    display: block; /* Remove extra space below images */
    margin: 0 auto; /* Center images if they are smaller than 100% */
}

/* Preview Elements */
.preview-element {
    text-align: center;
}
.preview-element a {
    text-decoration: none;
    color: inherit;
}
.preview-profile-gh-style, .preview-profile-tw-style {
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05);
}
.preview-profile-tw-style .profile-banner {
    height: 150px;
    background-color: #ccc;
    background-size: cover;
    background-position: center;
    border-radius: 12px 12px 0 0;
    margin: -20px -20px 10px -20px;
    position: relative;
    z-index: 1; /* Ensure banner is below avatar */
}
.preview-profile-tw-style .profile-avatar, .preview-profile-gh-style .profile-avatar, .preview-avatar-only .profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    object-fit: cover;
    position: relative; /* Needed for z-index to work */
    z-index: 2; /* Ensure avatar is above banner */
}
.preview-profile-tw-style .profile-avatar {
    margin-top: -60px;
}

.preview-avatar-only .profile-avatar {
     width: 120px;
    height: 120px;
}

.profile-nickname { font-weight: bold; font-size: 1.5rem; }
.profile-bio { font-size: 1rem; color: #555; }
.preview-link-row {
    display: block;
    padding: 15px;
    border: 1px solid rgba(0,0,0,0.1);
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    border-radius: 8px;
    transition: transform 0.2s;
    text-align: left; /* Added for left alignment */
}
.preview-link-row:hover {
    transform: scale(1.02);
}
.preview-link-row i {
    margin-right: 10px;
}
.preview-icon-matrix {
    display: flex;
    justify-content: center;
    gap: 20px;
}
.preview-icon-matrix a {
    font-size: 2rem;
}
.preview-text {
    text-align: left;
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.05);
}
.preview-separator {
    height: 1px;
    background-color: #ccc;
    margin: 10px 0;
}
.preview-announcement {
    /* Changed to flex for inline icon and text */
    display: flex;
    align-items: flex-start; /* Align icon and content at the top */
    text-align: left;
    font-weight: 500;
}
.preview-announcement i {
    flex-shrink: 0; /* Prevent icon from shrinking */
    margin-right: 10px; /* Space between icon and text */
    font-size: 1.25rem; /* Make icon slightly larger to match text */
    line-height: 1.5; /* Align icon vertically with first line of text */
}
.preview-announcement > div { /* Wrapper for Quill content */
    flex-grow: 1; /* Allow content to take up remaining space */
}

.preview-iframe {
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 8px;
}
.preview-collapsible summary {
    cursor: pointer;
    padding: 10px;
    background-color: rgba(240, 240, 240, 0.8);
    border-radius: 8px;
    font-weight: bold;
    list-style: none; /* Hide the disclosure triangle */
    text-align: left; /* Align text to the left */
}

.preview-collapsible .collapsible-content {
    padding: 10px;
    border-top: 1px solid #eee;
}

#icon-selector .icon-category {
    margin-bottom: 1rem;
}

#icon-selector .icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 10px;
}

#icon-selector .icon-item {
    cursor: pointer;
    font-size: 24px;
    text-align: center;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

#icon-selector .icon-item:hover, #icon-selector .icon-item.selected {
    background-color: #e9ecef;
}

/* Icon Picker Modal Styles */
.icon-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); /* Adjusted for better visibility */
    gap: 10px;
    max-height: 500px; /* Limit height and enable scrolling */
    overflow-y: auto;
    padding: 5px;
    border: 1px solid #eee;
    border-radius: 5px;
}

.icon-item {
    cursor: pointer;
    font-size: 28px; /* Slightly larger icons */
    text-align: center;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s, transform 0.1s;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
}

.icon-item:hover {
    background-color: #e2e6ea;
    transform: scale(1.05);
}

.tox-tinymce-aux {
    z-index: 1061 !important; /* Bootstrap modal z-index is 1060 */
}
/* Ensure icon picker modal is above element editor modal */
#iconPickerModal.modal {
    z-index: 1070; /* Higher than elementEditorModal (1050) */
}
#elementEditorModal.modal {
    z-index: 1050;
}
.modal-backdrop.fade.show {
    z-index: 1049; /* Make sure backdrop is behind editor modal */
}

#help-pane pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    white-space: pre-wrap;
    word-break: break-all;
}

.unsaved-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    height: 10px;
    width: 10px;
    background-color: red;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid white;
}