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

body {
    min-width: 768px; /* Prevent layout breaking on very small screens */
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #4a90e2;
    color: white;
    padding: 10px 20px;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 768px; /* Match body min-width */
}

.top-bar .title-container {
    font-size: 1.5em;
    display: flex;
    align-items: baseline;
    gap: 0.5em;
}

.top-bar .main-title {
    font-weight: normal;
}

.top-bar .subtitle {
    font-weight: bold;
    opacity: 0.9;
}

.main-content {
    margin-top: 75px;
    display: grid;
    grid-template-columns: minmax(200px, 250px) 1fr; /* Flexible nav width */
    height: calc(100vh - 75px);
    overflow: hidden;
    min-width: 768px; /* Match body min-width */
}

.nav-column {
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    padding: 20px;
    overflow-y: auto;
    min-width: 200px; /* Minimum nav width */
    max-width: 250px; /* Maximum nav width */
    /* Make sure the nav column has enough height to show all items */
    max-height: calc(100vh - 105px); /* 75px for top margin + 30px for footer */
}

.nav-title {
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4a90e2;
    white-space: nowrap; /* Prevent title wrapping */
}

.nav-subtitle {
    font-size: 1.0em;
    font-weight: 600;
    color: #4a90e2;
    margin-top: 12px; /* Reduced from 20px */
    margin-bottom: 10px; /* Reduced from 20px */
    padding-bottom: 6px; /* Reduced from 10px */
    border-bottom: 2px solid #4a90e2;
    white-space: nowrap; /* Prevent title wrapping */
}

.nav-list {
    list-style: none;
    padding-bottom: 15px; /* Add padding at the bottom of the nav list */
    padding-left: 10px; /* Add left padding to all menu items */
}

/* Reduce spacing between nav items */
.nav-list li {
    margin-bottom: 2px; /* Reduced from 5px */
}

/* Space between sections but less than before */
.nav-list li button[data-page="pages/about-page.html"],
.nav-list li button[data-page="pages/changes-page.html"],
.nav-list li button[data-page="pages/technical-page.html"],
.nav-list li button[data-page="pages/cf-notes-page.html"] {
    margin-top: 8px; /* Reduced from 15px */
}

/* Improve button clickability and accessibility */
.nav-list button {
    width: 100%;
    text-align: left;
    padding: 6px 12px; /* Reduced vertical padding from 10px to 6px */
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease; /* Smooth transitions */
    position: relative; /* For focus indicator positioning */
}

.nav-list button:hover {
    background-color: #e9ecef;
}

.nav-list button.active {
    background-color: #4a90e2;
    color: white;
}

/* Add visual feedback when clicking menu items */
.nav-list button:active {
    background-color: #357ab8;
    color: white;
}

/* Improve focus visibility for keyboard navigation */
.nav-list button:focus {
    outline: 2px solid #4a90e2; /* Clear focus indicator */
}

/* Add visual indicator for keyboard focus */
.nav-list button:focus:not(:focus-visible) {
    outline: none; /* Remove outline for mouse focus */
}

.nav-list button:focus-visible {
    outline: 2px solid #4a90e2; /* Keep outline for keyboard focus */
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.2); /* Add subtle glow */
}

/* Ensure active (selected) button text remains white even when focused */
.nav-list button.active:focus {
    background-color: #4a90e2; /* Keep the active background color */
    color: #333333; /* Keep the text white */
}

/* Ensure non-active buttons get a light highlight when focused */
.nav-list button:not(.active):focus {
    background-color: rgba(74, 144, 226, 0.1); /* Light highlight for non-active buttons */
    color: inherit; /* Keep original text color */
}

.content-area {
    overflow: hidden;
    height: 100%;
    min-width: 500px; /* Ensure minimum content width */
    position: relative; /* For watermark positioning */
}

/* Watermark styles */
.content-watermark {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2; /* Above iframe but below loading indicator */
}

.content-watermark::after {
    content: "DRAFT";
    font-size: 120px;
    color: rgba(128, 128, 128, 0.2);
    transform: rotate(-45deg);
    white-space: nowrap;
    letter-spacing: 20px;
    pointer-events: none;
}

#content-container {
    height: 100%;
    width: 100%;
    border: none;
}

.loading {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1001; /* Above top bar */
}

.loading.active {
    display: block;
}

/* Provenance button styling */
.provenance-button {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: white;
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s;
}

.provenance-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.info-icon {
    font-size: 1.2em;
}

/* Provenance panel styling */
.provenance-panel {
    position: fixed;
    top: 0;
    right: -400px; /* Start off-screen */
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    transition: right 0.3s ease;
    z-index: 1100;
}

.provenance-panel.active {
    right: 0;
}

.provenance-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.provenance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.provenance-header h3 {
    margin: 0;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #666;
    padding: 0 5px;
}

.close-btn:hover {
    color: #333;
}

#provenance-text {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 10px;
    line-height: 1.6;
    color: #444;
}

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    z-index: 1000;
    min-width: 768px; /* Match body min-width */
}

.footer-content {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    color: #666;
    font-size: 0.9em;
}

.footer-content a {
    color: #4a90e2;
    text-decoration: none;
    margin: 0 10px;
}

.footer-content a:hover {
    text-decoration: underline;
}

/* Add a message for very small screens */
@media (max-width: 767px) {
    body::before {
        content: "Please use a larger screen for optimal viewing";
        display: block;
        padding: 20px;
        text-align: center;
        background: #fff3cd;
        color: #856404;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 2000;
    }
}