body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background-color: #1e1e1e;
    color: #f0f0f0;
    display: flex;
    flex-direction: column; /* Changed to column to push footer to bottom */
    justify-content: space-between; /* Distribute space to push footer down */
    min-height: 100vh;
    box-sizing: border-box;
}

/* Top menu container for full width and centering */
.top-menu-container {
    width: 100%;
    background-color: #282828;
    border-bottom: 1px solid #3a3a3a;
    padding: 10px 20px;
    box-sizing: border-box;
    display: flex;
    justify-content: center; /* Center the actual menu */
}

.top-menu {
    display: flex;
    gap: 15px; /* Space between tabs */
    max-width: 1400px; /* Align with main content max-width */
    width: 100%; /* Take full width of its container */
    justify-content: flex-start; /* Align tabs to the left within their max-width */
}

.tab-button {
    background-color: transparent;
    color: #88c0d0;
    border: none;
    padding: 10px 15px;
    font-size: 1.1em;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
    border-bottom: 3px solid transparent; /* For active indicator */
    font-weight: bold;
}

.tab-button:hover {
    color: #f0f0f0;
    background-color: #3a3a3a;
}

.tab-button.active {
    color: #007bff;
    border-bottom: 3px solid #007bff;
    background-color: #3a3a3a;
}

/* Main content wrapper to hold both reader and changelog tabs */
.main-content-wrapper {
    display: flex; /* Changed from display: block, to allow flex-direction column on itself if tabs are stacked */
    flex-grow: 1; /* Allow to take up remaining vertical space */
    width: 100%;
    max-width: 1400px;
    margin: 0 auto; /* Center the wrapper */
    /* Removed position: relative as tabs are no longer absolute */
}

/* Base styles for all tab content */
.tab-content {
    width: 100%;
    /* Removed height: 100%; and position: absolute; top: 0; left: 0; */
    display: none; /* Hidden by default */
    /* overflow-y: auto; - Removed here, will be on specific content areas if needed */
    box-sizing: border-box;
}

.tab-content.active {
    display: block; /* Default block to allow content to flow */
}

/* Specific adjustment for the reader tab content to maintain sidebar layout */
#foundry-reader-tab-content.tab-content.active {
    display: flex; /* Keep flex for sidebar and main content */
    flex-grow: 1; /* Allow it to grow */
}


.sidebar {
    width: 280px;
    background-color: #282828;
    border-right: 1px solid #3a3a3a;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    height: 100%; /* Changed to 100% to stretch within flex parent */
    transition: transform 0.3s ease-in-out; /* For mobile slide-in */
}

/* Mobile sidebar styling */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh; /* Use vh for fixed height relative to viewport */
        transform: translateX(-100%); /* Hidden by default */
        z-index: 1000;
        box-shadow: 2px 0 5px rgba(0,0,0,0.5);
    }

    .sidebar.active {
        transform: translateX(0); /* Show when active */
    }

    .mobile-menu-overlay {
        display: none; /* Hidden by default */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .mobile-menu-overlay.active {
        display: block; /* Show when active */
    }

    .journal-content-area {
        width: 100%; /* Take full width on small screens */
    }

    /* Show hamburger button on mobile only */
    .open-sidebar-btn {
        display: block; /* Managed by JS instead of !important */
        margin-right: 15px; /* Space between button and content */
    }

    /* Show close button on mobile sidebar only */
    .close-sidebar-btn {
        display: block; /* Managed by JS instead of !important */
        background: none;
        border: none;
        color: #f0f0f0;
        font-size: 1.5em;
        cursor: pointer;
    }

    /* Adjust deload button for mobile when it's at the bottom */
    .deload-button-container {
        margin-top: 20px; /* Space above the button */
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .deload-button {
        width: calc(100% - 40px) !important; /* Adjust width to fit content area padding */
        margin: 0 !important; /* Remove specific margins from previous location */
    }
}

/* Hide open-sidebar-btn by default on larger screens */
.open-sidebar-btn {
    display: none; /* Managed by JS */
}

/* Hide close-sidebar-btn by default on larger screens */
.close-sidebar-btn {
    display: none; /* Managed by JS */
}


.sidebar h2 {
    color: #e0e0e0;
    margin-top: 0;
    margin-bottom: 0; /* Adjusted for sidebar-header */
    padding-bottom: 0; /* Adjusted for sidebar-header */
    border-bottom: none; /* Adjusted for sidebar-header */
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar ul li {
    margin-bottom: 8px;
}

/* Indentation based on level */
.sidebar ul li.level-1-item a {
    padding-left: 10px;
}

.sidebar ul li.level-2-item a {
    padding-left: 25px;
}

.sidebar ul li.level-3-item a {
    padding-left: 40px;
}

/* Spacing between levels */
.sidebar ul li.level-1-item {
    margin-top: 15px;
    margin-bottom: 5px;
}

.sidebar ul li.level-2-item {
    margin-top: 10px;
    margin-bottom: 5px;
}

.sidebar ul li.level-3-item {
    margin-top: 0;
    margin-bottom: 5px;
}

.sidebar ul li a {
    color: #88c0d0;
    text-decoration: none;
    display: block;
    padding-top: 5px;
    padding-bottom: 5px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar ul li a:hover {
    background-color: #3a3a3a;
}

.sidebar ul li a.active {
    background-color: #007bff;
    color: white;
    font-weight: bold;
}

.journal-content-area {
    flex-grow: 1; /* Added to make the content area expand and push footer down */
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.navigation-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 900px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #3a3a3a;
}

.navigation-buttons.top-nav {
    position: sticky;
    top: 0;
    background-color: #1e1e1e;
    z-index: 100;
    padding-top: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.navigation-buttons.bottom-nav {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #3a3a3a;
    border-bottom: none;
}

.navigation-buttons button {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.navigation-buttons button:hover {
    background-color: #0056b3;
}

.navigation-buttons button:disabled {
    background-color: #555;
    cursor: not-allowed;
}

#page-indicator-top,
#page-indicator-bottom {
    color: #e0e0e0;
    font-size: 1.1em;
    font-weight: bold;
    flex-grow: 1;
    text-align: center;
}

/* Container for the de-load button at the bottom */
.deload-button-container {
    width: 100%;
    max-width: 900px;
    margin-top: 30px; /* Space above the button */
    display: flex;
    justify-content: center;
    padding-bottom: 20px; /* Padding for the very bottom */
}

.deload-button {
    background-color: #dc3545 !important;
    width: 200px; /* Fixed width for larger screens */
    margin: 0; /* Reset margins */
}

.deload-button:hover {
    background-color: #c82333 !important;
}


.journal-container {
    background-color: #282828;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    padding: 30px;
    width: 100%;
    max-width: 900px;
    box-sizing: border-box;
}

#journal-title {
    text-align: center;
    color: #e0e0e0;
    margin-bottom: 25px;
    font-size: 2.5em;
    border-bottom: 2px solid #3a3a3a;
    padding-bottom: 15px;
}

.journal-page {
    display: none;
    padding: 20px 0;
    line-height: 1.6;
    font-size: 1.1em;
}

.journal-page.active {
    display: block; /* Ensures only active page is visible */
}

.journal-page h1,
.journal-page h2,
.journal-page h3,
.journal-page h4,
.journal-page h5,
.journal-page h6 {
    color: #c0c0c0;
    margin-top: 20px;
    margin-bottom: 15px;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}

.journal-page p {
    margin-bottom: 1em;
}

.journal-page ul {
    list-style-type: disc;
    margin-left: 25px;
    margin-bottom: 1em;
}

.journal-page blockquote {
    border-left: 4px solid #555;
    padding-left: 15px;
    margin-left: 0;
    font-style: italic;
    color: #aaa;
}

.journal-page pre {
    background-color: #333;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95em;
}

.journal-page hr {
    border: none;
    border-top: 1px solid #444;
    margin: 25px 0;
}

/* Specific styling for the "secret revealed" sections often found in Foundry VTT exports */
.journal-page section.secret.revealed {
    background-color: #333;
    border: 1px solid #555;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 1em;
}

.journal-page section.secret.revealed p {
    margin: 0.5em 0;
}

.journal-page .secret.revealed span[style*="font-family:Modesto Condensed"] {
    font-family: 'Times New Roman', serif !important;
    font-weight: bold;
}

.journal-page .secret.revealed strong[data-start][data-end] {
    color: #fff;
}

/* Styling for @UUID links */
.journal-page a.journal-link {
    color: #88c0d0;
    text-decoration: none;
    font-weight: bold;
}

.journal-page a.journal-link:hover {
    text-decoration: underline;
}

/* New style for broken links */
.journal-page a.broken-journal-link {
    color: #dc3545; /* Red color for broken links */
    text-decoration: none; /* Keep it underlined on hover by default, or add specific hover */
    font-weight: bold;
    pointer-events: auto; /* Ensure it's clickable */
}

.journal-page a.broken-journal-link:hover {
    text-decoration: underline;
}

.journal-page a.broken-journal-link .fas {
    margin-right: 5px; /* Space between icon and text */
}


/* Add styling for the broken image icon */
.broken-image-icon {
    color: #dc3545; /* Red color for the icon */
    font-size: 1.5em; /* Make it noticeable */
    margin: 15px auto; /* Center it, same margin as images */
    display: block; /* Ensure it takes up its own line */
}


/* Handle specific errors from the Foundry VTT export */
.journal-page pre code[style*="color:red"] {
    color: red;
}

/* Styles for images within journal pages */
.journal-page img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 15px auto;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Drag and Drop Zone Styles */
#upload-zone {
    display: block;
    border: 2px dashed #007bff;
    padding: 40px;
    text-align: center;
    margin-bottom: 20px;
    background-color: #2f2f2f;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#upload-zone:hover {
    background-color: #3a3a3a;
}

#upload-zone.dragover {
    border-color: #28a745;
    background-color: #3a3f4a;
}

#upload-zone p {
    margin: 0;
    color: #c0c0c0;
}

#upload-zone label {
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
}

#uploaded-file-name {
    display: block;
    margin-top: 10px;
    font-weight: bold;
    color: #e0e0e0;
}

.error-message {
    color: #dc3545;
    margin-top: 10px;
    font-weight: bold;
}

/* Description Area Styles */
.description-area {
    display: block; /* Ensure visible by default when no JSON is loaded */
    margin-top: 20px;
    padding: 20px;
    background-color: #282828;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 900px;
    box-sizing: border-box;
    text-align: left;
}

.description-area h3 {
    color: #e0e0e0;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.5em;
}

.description-area p {
    margin-bottom: 1em;
    line-height: 1.5;
}

/* Styles for the pre-made list in the sidebar */
.sidebar ul li.premade-item a {
    color: #88c0d0;
    text-decoration: none;
    display: block;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.sidebar ul li.premade-item a:hover {
    background-color: #3a3a3a;
}

.sidebar ul.premade-list-container {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #444;
}

.sidebar ul.premade-list-container li {
    margin-bottom: 5px;
}

.sidebar ul.premade-list-container .premade-list-heading {
    font-size: 1.1em;
    font-weight: bold;
    color: #e0e0e0;
    margin-bottom: 10px;
    padding-left: 0;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #282828;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    text-align: center;
    color: #f0f0f0;
}

.modal-content h2 {
    margin-top: 0;
    color: #e0e0e0;
    font-size: 1.8em;
}

.modal-content p {
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-content input[type="text"] {
    width: calc(100% - 20px);
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #444;
    border-radius: 5px;
    background-color: #3a3a3a;
    color: #f0f0f0;
    font-size: 1em;
}

.modal-content input[type="text"]::placeholder {
    color: #888;
}

.modal-buttons {
    display: flex;
    justify-content: center;
}

.modal-buttons button {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px 25px;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.modal-buttons button:hover {
    background-color: #0056b3;
}

/* Footer Styles */
footer {
    background-color: #282828;
    color: #888;
    text-align: center;
    padding: 20px;
    margin-top: 40px; /* Space above the footer */
    border-top: 1px solid #3a3a3a;
    font-size: 0.9em;
}

footer p {
    margin: 5px 0;
}
footer a {
    color: #88c0d0;
    text-decoration: none;
}

/* Changelog specific styles */
.changelog-container {
    padding: 20px;
    background-color: #282828;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 900px;
    margin: 20px auto; /* Center it and add space */
    box-sizing: border-box;
    text-align: left; /* Align text to left inside changelog container */
}

.changelog-container h2 {
    text-align: center;
    color: #e0e0e0;
    margin-bottom: 25px;
    font-size: 2em;
    border-bottom: 2px solid #3a3a3a;
    padding-bottom: 15px;
}

.changelog-entry {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px dashed #444;
    overflow: hidden; /* Added to explicitly contain floated content */
}

.changelog-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.changelog-entry h3 {
    color: #c0c0c0;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.5em;
}

/* Styles for text items with bullet points */
.changelog-entry .changelog-text-item {
    position: relative;
    padding-left: 25px; /* Indent text items for bullet */
    margin-bottom: 8px; /* Space between text items */
    color: #d0d0d0;
}

.changelog-entry .changelog-text-item::before {
    content: '\2022'; /* Unicode for a bullet point */
    color: #007bff; /* Color the bullet */
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em; /* Negative margin to pull bullet back */
    position: absolute; /* Position bullet precisely */
    left: 0; /* Align to the start of padding */
    top: 0; /* Align with text top */
}


/* Styling for aligned images and videos */
.changelog-entry .media-wrapper {
    margin-top: 15px; /* Spacing between content and media */
    margin-bottom: 15px;
    box-sizing: border-box; /* Ensure padding/border is included in width calculation */
}

.changelog-entry .align-left {
    float: left;
    margin-right: 20px; /* Space to the right when floated left */
    max-width: calc(50% - 20px); /* Adjusted max-width to account for its own margin */
}

.changelog-entry .align-right {
    float: right;
    margin-left: 20px; /* Space to the left when floated right */
    max-width: calc(50% - 20px); /* Adjusted max-width to account for its own margin */
}

.changelog-entry .align-center {
    display: block; /* Ensures block behavior for centering */
    margin-left: auto;
    margin-right: auto;
    text-align: center; /* Ensure content inside is aligned */
}

/* Clearfix for floats */
.changelog-entry::after {
    content: "";
    display: table;
    clear: both;
}
