:root {
    /* Light theme (default) */
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --light-gray: #f8f9fa;
    --dark-gray: #343a40;
    --border-color: #dee2e6;
    --text-color: #212529;
    --background-color: #e9ecef;
    --card-background: #ffffff;
    --search-result-hover: #f1f3f5;
    --search-result-selected: #007bff;
    --search-result-selected-text: #ffffff;
    --button-hover: #0056b3;
    --button-secondary-hover: #5a6268;
    --role-definition-bg: #f8f9fa;
    --category-active-bg: #007bff;
    --category-active-text: #ffffff;
    --category-hover-bg: #e2e6ea;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --modal-overlay-bg: rgba(0, 0, 0, 0.6);
    --progress-bar-bg: #28a745; /* Green for progress bar */
}

/* Dark theme */
html[data-theme='dark'] {
    --primary-color: #0d6efd;
    --secondary-color: #adb5bd;
    --light-gray: #2b3035;
    --dark-gray: #f8f9fa;
    --border-color: #495057;
    --text-color: #e9ecef;
    --background-color: #212529;
    --card-background: #343a40;
    --search-result-hover: #495057;
    --search-result-selected: #0d6efd;
    --search-result-selected-text: #ffffff;
    --button-hover: #0b5ed7;
    --button-secondary-hover: #98a0a7;
    --role-definition-bg: #2c3136;
    --category-active-bg: #0d6efd;
    --category-active-text: #ffffff;
    --category-hover-bg: #495057;
    --modal-overlay-bg: rgba(0, 0, 0, 0.7);
    --progress-bar-bg: #2db950; /* Slightly brighter green for dark mode */
}

body {
    font-family: var(--font-family);
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 15px;
    transition: background-color 0.3s ease, color 0.3s ease, margin-left 0.3s ease;
    position: relative;
    min-height: 100vh;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

/* Hide scrollbars */
::-webkit-scrollbar {
    width: 8px; /* Make scrollbars subtle if shown */
    height: 8px;
}
::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}
::-webkit-scrollbar-track {
    background: var(--light-gray);
}

* {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--secondary-color) var(--light-gray); /* Firefox */
    /* -ms-overflow-style: none;  IE and Edge - consider if needed */
}


.main-content {
    transition: margin-left 0.3s ease;
    width: 100%;
}

body.console-open .main-content {
    margin-left: 320px; /* Width of the sidebar */
}

.container {
    max-width: 900px;
    margin: 20px auto;
    padding: 20px;
    background-color: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Align items vertically */
    margin-bottom: 25px;
    flex-wrap: wrap; /* Allow header items to wrap on small screens */
    gap: 10px;
}

.header-content {
    display: flex;
    flex-direction: column;
}

.header-attribution {
    font-size: 0.75rem;
    color: var(--secondary-color);
    margin-top: 3px;
}

.header-attribution a {
    color: var(--text-color); /* Adjusted for better visibility */
    text-decoration: none;
    transition: color 0.3s ease;
}
html[data-theme='dark'] .header-attribution a {
    color: var(--light-gray); 
}
.header-attribution a span { text-decoration: underline; }
.header-attribution a:hover { opacity: 0.8; }


.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

h1 {
    color: var(--dark-gray); /* Should be --text-color or a specific heading color */
    margin: 0 0 5px 0; /* Adjusted margin */
    transition: color 0.3s ease;
    font-size: 1.8rem; /* Slightly larger */
}
html[data-theme='dark'] h1 {
    color: var(--text-color);
}


.btn, .btn-refresh, .btn-theme { /* Combined base style for all primary action buttons */
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 8px 15px;
    font-size: 0.95rem;
    transition: background-color 0.3s ease, opacity 0.3s ease, transform 0.2s ease;
    display: inline-flex; /* Use inline-flex for better icon alignment */
    align-items: center;
    justify-content: center;
    gap: 8px; /* Increased gap */
    border: 1px solid transparent; /* For hover/focus consistency */
    height: 38px; 
    line-height: 1.5; /* Ensure text is centered vertically */
    text-decoration: none; /* For <a> styled as button */
}

.btn:hover, .btn-refresh:hover, .btn-theme:hover {
    background-color: var(--button-hover);
    opacity: 0.9;
}
.btn:active, .btn-refresh:active, .btn-theme:active {
    transform: translateY(1px);
}


.btn-secondary { /* Style for secondary buttons like Exit */
    background-color: var(--secondary-color);
}
.btn-secondary:hover {
    background-color: var(--button-secondary-hover);
}


.btn-theme { /* Specific for theme toggle */
    width: 38px;
    padding: 0; /* Remove padding if fixed width/height */
}

.btn i, .btn-refresh i, .btn-theme i {
    font-size: 1.1rem; 
}

#copyModeButton { /* Now uses .btn, specific overrides if any */
    min-width: 100px; /* Example specific override */
}
#copyModeButton:disabled {
    background-color: var(--light-gray);
    color: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.7;
}
html[data-theme='dark'] #copyModeButton:disabled {
     background-color: var(--border-color);
}


.btn-refresh.checking { animation: checking 1s infinite; }
.btn-refresh.success { animation: success-pulse 1.5s; }
.btn-refresh.no-update { animation: no-update-pulse 1.5s; }

@keyframes checking { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes success-pulse {
    0% { border-color: transparent; box-shadow: none; }
    25% { border-color: var(--progress-bar-bg); box-shadow: 0 0 8px var(--progress-bar-bg); }
    75% { border-color: var(--progress-bar-bg); box-shadow: 0 0 8px var(--progress-bar-bg); }
    100% { border-color: transparent; box-shadow: none; }
}
@keyframes no-update-pulse { /* ... existing ... */ }

html[data-theme='light'] .dark-icon { display: none; }
html[data-theme='dark'] .light-icon { display: none; }

.search-container { margin-bottom: 20px; }
#searchInput {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem; /* Standardized font size */
    box-sizing: border-box;
    background-color: var(--card-background);
    color: var(--text-color);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}
#searchInput:focus { /* ... existing ... */ }

.category-container { /* ... existing ... */ }
.category-selector { /* ... existing ... */ }
.category-btn { /* ... existing ... */ }
.category-btn:hover { /* ... existing ... */ }
.category-btn.active { /* ... existing ... */ }

#searchResults { /* ... existing ... */ }
#searchResults li { /* ... existing ... */ }
#searchResults li:last-child { border-bottom: none; }
#searchResults li:hover { background-color: var(--search-result-hover); }
#searchResults li.selected { background-color: var(--search-result-selected); color: var(--search-result-selected-text); }

.mode-display-container { /* ... existing ... */ }
.mode-label { /* ... existing ... */ }
#modeNameDisplay { /* ... existing ... */ }

.details-container { /* ... existing ... */ }
.details-container h2, .details-container h3 { /* ... existing ... */ }
.details-container ul { /* ... existing ... */ }
.details-container li { /* ... existing ... */ }
.details-container strong { /* ... existing ... */ }
.role-definition { /* ... existing ... */ }
.role-definition p { /* ... existing ... */ }
.role-definition ul { /* ... existing ... */ }
.badge { /* ... existing ... */ }
.badge-groups { /* ... existing ... */ }
.badge-category { background-color: var(--secondary-color); }
.mode-emoji { /* ... existing ... */ }
.no-results { /* ... existing ... */ }

/* Developer Console Sidebar Styling */ /* ... existing ... */
.dev-console-sidebar { /* ... existing ... */ }
.dev-console-sidebar.open { /* ... existing ... */ }
.console-header { /* ... existing ... */ }
.console-header h2 { /* ... existing ... */ }
.close-btn { /* ... existing ... */ }
.close-btn:hover { /* ... existing ... */ }
.console-body { /* ... existing ... */ }
.console-tabs { /* ... existing ... */ }
.console-tab { /* ... existing ... */ }
.console-tab.active { /* ... existing ... */ }
.console-tab.active::after { /* ... existing ... */ }
.tab-content { /* ... existing ... */ }
.console-log-container { /* ... existing ... */ }
#consoleLog { /* ... existing ... */ }
.console-controls, .action-section { /* ... existing ... */ }
.action-section { /* ... existing ... */ }
.action-section:last-child { /* ... existing ... */ }
.action-section h3 { /* ... existing ... */ }
.action-section p { /* ... existing ... */ }
.btn-group { /* ... existing ... */ }
.log-entry { /* ... existing ... */ }
.log-entry.info { /* ... existing ... */ }
.log-entry.success { /* ... existing ... */ }
.log-entry.warning { /* ... existing ... */ }
.log-entry.error { /* ... existing ... */ }
.log-timestamp { /* ... existing ... */ }
.version-number { /* ... existing ... */ }
.version-number:after { /* ... existing ... */ }
.version-number:hover:after { /* ... existing ... */ }

/* Confirmation Modal Styling */ /* ... existing, minor tweaks if needed from previous pass ... */
.confirm-modal { /* ... existing ... */ }
.confirm-dialog { /* ... existing ... */ }
@keyframes fadeInOverlay { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInDialog { from { opacity: 0; transform: translateY(-30px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.confirm-dialog h3 { /* ... existing ... */ }
.confirm-dialog p { /* ... existing ... */ }
.confirm-actions { /* ... existing ... */ }
.btn-no { background-color: var(--secondary-color); }
.btn-yes { background-color: #dc3545; }
.btn-yes:hover { background-color: #c82333; }


/* Custom .roomodes & Role Definition Modal Styling */
.modal-overlay {
    display: none; 
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--modal-overlay-bg);
    z-index: 1050; 
    justify-content: center;
    align-items: center;
    animation: fadeInOverlay 0.3s ease;
    padding: 20px; 
}

.modal-card {
    background-color: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    width: 100%; /* Full width within padding */
    max-width: 650px; /* Slightly wider max */
    animation: fadeInDialog 0.3s ease-out;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px); /* Max height considering padding */
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.modal-header h2 { margin: 0; font-size: 1.4rem; color: var(--text-color); }

.close-modal-btn {
    background: none; border: none; font-size: 1.8rem; cursor: pointer;
    color: var(--secondary-color); transition: color 0.3s ease;
    padding: 5px; line-height: 1;
}
.close-modal-btn:hover { color: var(--text-color); }

.modal-body {
    padding: 20px;
    overflow-y: auto; 
    flex-grow: 1; /* Allow body to take available space and scroll */
}
.modal-view { /* Class for different views within modal body */
    display: none; /* Hidden by default, shown by JS */
}
.modal-view.active {
    display: block;
}


.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end; /* Align buttons to the right by default */
    gap: 10px;
    flex-shrink: 0; /* Prevent footer from shrinking */
    background-color: var(--card-background); /* Ensure footer bg matches card */
}
/* Specific footer alignments if needed */
#downloadFullFooter, #selectModesFooter {
    display: none; /* Controlled by JS */
    width: 100%; /* Take full width of footer */
    justify-content: space-between; /* Example: space out buttons */
}
#selectModesFooter .btn:first-child { /* Example: if Save is on left, Exit on right */
    margin-right: auto;
}


.modal-content p { margin-bottom: 15px; line-height: 1.6; } /* old, .modal-body now primary */

.modal-btn { /* General button style within modals, inherits from .btn */
    width: auto; /* Allow button to size to content or be controlled by flex */
    margin-top: 0; /* Remove default top margin */
}
/* Ensure modal buttons take full width if they are the only item in a flex line */
.modal-body .btn.modal-btn { /* For buttons directly in modal-body like initial view */
    width: 100%;
    margin-bottom: 10px; /* Add some space between full-width buttons */
}
.modal-body .btn.modal-btn:last-child {
    margin-bottom: 0;
}


.scrollable-list {
    max-height: 280px; /* Adjusted height */
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 15px;
    background-color: var(--light-gray);
}
.scrollable-list .list-item {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px; /* Space between checkbox/label and role button */
}
.scrollable-list .list-item:last-child { border-bottom: none; }
.scrollable-list .list-item label { flex-grow: 1; cursor: pointer; }
.scrollable-list .list-item input[type="checkbox"] { margin-right: 10px; cursor: pointer; flex-shrink: 0; }
.scrollable-list .release-link { color: var(--primary-color); text-decoration: none; font-weight: 500; }
.scrollable-list .release-link:hover { text-decoration: underline; }
.scrollable-list .release-details { font-size: 0.85rem; color: var(--secondary-color); margin-left: 10px; }
.btn-role { /* Style for the new "Role" button in select modes */
    padding: 5px 10px;
    font-size: 0.8rem;
    background-color: var(--secondary-color);
    color: white;
    flex-shrink: 0;
}
.btn-role:hover {
    background-color: var(--button-secondary-hover);
}


#downloadProgressContainer {
    margin-top: 15px;
    margin-bottom: 15px; /* Space it from buttons */
    opacity: 1;
    transition: opacity 0.5s ease-out;
}
#downloadProgressContainer.fade-out {
    opacity: 0;
}
#downloadProgressContainer label { display: block; margin-bottom: 5px; font-weight: 500; }
#downloadProgressBar {
    width: 100%;
    height: 12px; /* Slimmer bar */
    border-radius: 6px;
    overflow: hidden; /* Ensures inner bar respects border-radius */
    background-color: var(--border-color); /* Background of the track */
}
#downloadProgressBar::-webkit-progress-bar {
    background-color: var(--border-color);
    border-radius: 6px;
}
#downloadProgressBar::-webkit-progress-value {
    background-color: var(--progress-bar-bg);
    border-radius: 6px 0 0 6px; /* Keep left radius, remove right if not full */
    transition: width 0.1s linear;
}
#downloadProgressBar::-moz-progress-bar {
    background-color: var(--progress-bar-bg);
    border-radius: 6px;
}
#downloadProgressBar[value="100"]::-webkit-progress-value {
    border-radius: 6px; /* Full radius when complete */
}


.select-modes-controls { display: flex; gap: 10px; margin-bottom: 10px; }
.btn-small { /* ... existing ... */ }

.role-definition-popup-content {
    white-space: pre-wrap; /* Preserve formatting of role definition */
    font-family: var(--font-family);
    line-height: 1.6;
}


/* Responsive adjustments */
@media (max-width: 768px) {
    .dev-console-sidebar { width: 280px; left: -280px; }
    body.console-open .main-content { margin-left: 0; }
    .dev-console-sidebar.open { left: 0; width: 100%; } /* Full width on mobile */
    body.console-open::after { /* ... existing ... */ }
    .modal-card { max-width: calc(100% - 20px); margin: 10px; max-height: calc(100vh - 20px); } /* Adjust for smaller screens */
    .header-controls { justify-content: space-around; } /* Better spacing for header buttons */
}

@media (max-width: 600px) {
    body { padding: 10px; }
    .container { padding: 15px; margin: 10px auto; }
    h1 { font-size: 1.6rem; }
    header { flex-direction: column; align-items: stretch; gap: 15px; }
    .header-controls { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px;}

    .category-selector { /* ... existing ... */ }
    .mode-display-container { flex-direction: column; align-items: stretch; }
    #modeNameDisplay { margin-bottom: 10px; }
    #copyModeButton { width: 100%; }

    .modal-header h2 { font-size: 1.2rem; }
    .modal-btn { font-size: 0.95rem; }
    .modal-footer { flex-direction: column; gap: 10px; } /* Stack footer buttons */
    .modal-footer .btn { width: 100%; }
    #selectModesFooter .btn:first-child { margin-right: 0; } /* Remove auto margin */


    .confirm-dialog { padding: 20px; }
    .confirm-dialog h3 { font-size: 1.1rem; }
    .confirm-dialog p { font-size: 0.9rem; }
}
