.lock-toggle.locked {
    background: rgba(0, 0, 128, 0.1);
    color: #000080;
}
.beta-notice {
    display: none; /* Hidden on desktop, rotating messages shown instead */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.2px;
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
    line-height: 1.3;
}
.beta-notice strong {
    font-weight: 600;
}
.reader-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 20px;
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--reverie-core-color, #734ba1) 90%, white), 
        var(--reverie-core-color, #734ba1), 
        color-mix(in srgb, var(--reverie-core-color, #734ba1) 80%, black));
    border-bottom: 3px solid rgba(0, 0, 0, 0.4);
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    z-index: 10100; /* Above drawer (9997 desktop, 10000 mobile) */
    min-height: 44px;
    transition: none;
}
.enhanced-reader {
    margin: 0;
    max-width: none;
    width: 100%;
    border: none;
    background-color: #ffffff;
    display: block;
}
.header-wrapper {
    min-height: auto;
}
.header-unified {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 32px;
    gap: 40px;
    position: relative;
}
.header-unified .logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    padding: 0;
    transition: none;
}
.header-unified .logo-link:hover,
.mobile-logo-link:hover {
    background: none;
}
.header-unified .logo-link:hover .header-logo,
.mobile-logo-link:hover .mobile-logo {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}
.header-unified .header-logo {
    height: 40px;
    width: auto;
    filter: none;
}

/* errantson Helper Button */
.errantson-helper {
    position: relative;
    width: 36px;
    height: 36px;
    min-width: 36px; /* Prevent shrinking */
    min-height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    flex-shrink: 0;
}

.errantson-helper img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.errantson-helper:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

.errantson-helper:hover img {
    transform: scale(1.1);
}

.errantson-helper:active {
    transform: scale(0.95);
}

/* Mobile helper specific styling */
.errantson-helper.mobile-helper {
    width: 40px;
    height: 40px;
}

.errantson-helper.mobile-helper img {
    width: 28px;
    height: 28px;
}

/* Pulse effect - always gently pulses to attract attention */
.helper-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    pointer-events: none;
    animation: gentle-pulse 3s ease-in-out infinite;
}

/* Stronger pulse for has-unread or needs-attention */
.errantson-helper.has-unread .helper-pulse,
.errantson-helper.needs-attention .helper-pulse {
    animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes gentle-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.6;
    }
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Message notification badge */
.errantson-helper.has-messages::after {
    content: attr(data-count);
    position: absolute;
    top: -2px;
    left: -8px;
    background: #dc3545;
    color: white;
    font-size: 9px;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 1.5px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    z-index: 0;
}

.desktop-nav {
    display: flex;
}

/* Center Group: errantson + Message Display side by side */
.header-center-group {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 16px;
    pointer-events: auto;
    height: 44px;
}

.desktop-nav {
    display: flex;
    position: relative;
    gap: 8px;
}

/* Dropdown Navigation */
.nav-dropdown {
    position: relative;
}

/* Admin Dropdown Styling */
.nav-dropdown.admin-dropdown .nav-dropdown-trigger {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
}

.nav-dropdown.admin-dropdown .nav-dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nav-dropdown.admin-dropdown .nav-dropdown-menu {
    right: auto;
    left: 0;
}

.nav-dropdown.admin-dropdown #admin-logout-btn {
    border-top: 1px solid rgba(0, 0, 0, 0.15);
    color: #d32f2f;
    margin-top: 4px;
}

.nav-dropdown.admin-dropdown #admin-logout-btn:hover {
    background: rgba(211, 47, 47, 0.08);
    color: #c62828;
}

.nav-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.nav-dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.nav-dropdown-trigger.open {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.nav-current-icon {
    font-size: 16px;
}

.nav-current-label {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.nav-dropdown-arrow {
    font-size: 10px;
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.nav-dropdown-trigger.open .nav-dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 10500; /* Above dashboard (10000) and drawer (10001) */
}

.nav-dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    text-align: left;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: normal;
}

/* Ensure links don't show as purple */
.nav-dropdown-item:link,
.nav-dropdown-item:visited {
    color: #333;
}

.nav-dropdown-item:last-child {
    border-bottom: none;
}

.nav-dropdown-item:hover {
    background: rgba(107, 79, 155, 0.08);
    color: var(--reverie-core-color, #734ba1);
}

.nav-dropdown-item.current {
    background: rgba(107, 79, 155, 0.12);
    color: var(--reverie-core-color, #734ba1);
    font-weight: 600;
}

.nav-item-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Conveyor belt animation for Live Events calendar icon */
.nav-dropdown-item.conveyor-icon .nav-item-icon {
    position: relative;
    display: inline-block;
    width: 18px;
    height: 18px;
    overflow: hidden;
    font-size: 0; /* Hide the original emoji text */
}

.nav-dropdown-item.conveyor-icon .nav-item-icon::before,
.nav-dropdown-item.conveyor-icon .nav-item-icon::after {
    content: '📅';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    line-height: 1;
}

/* First emoji - starts visible in the viewport */
.nav-dropdown-item.conveyor-icon .nav-item-icon::before {
    left: 1px;
}

/* Second emoji - starts just outside viewport on the right */
.nav-dropdown-item.conveyor-icon .nav-item-icon::after {
    left: 19px;
}

/* On hover, both slide left creating conveyor effect */
.nav-dropdown-item.conveyor-icon:hover .nav-item-icon::before,
.nav-dropdown-item.conveyor-icon:hover .nav-item-icon::after {
    animation: conveyor-slide 0.3s linear infinite;
}

@keyframes conveyor-slide {
    from { transform: translateY(-50%) translateX(0); }
    to { transform: translateY(-50%) translateX(-18px); }
}

.nav-item-label {
    flex: 1;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: normal;
}

.nav-dropdown-item.current .nav-item-label {
    font-weight: 600;
}

/* Old nav styles - remove */
.icon-nav {
    display: none;
}

.nav-icon-btn {
    display: none;
}
.mobile-nav {
    display: none;
}
.mobile-menu {
    display: none;
}
.header-user-display {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.header-server-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 4px;
}
.header-user-name {
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Header Message Display (Rotating Messages) */
.header-message-display {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    letter-spacing: 0.2px;
    text-align: center;
    white-space: normal;
    width: 280px; /* Fixed width for consistent layout */
    height: 36px; /* Fixed height for 2 lines */
    line-height: 1.3;
    transition: opacity 0.6s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Clip any overflow */
}

.header-message-display.fade-out {
    opacity: 0;
}

.header-message-display.fade-in {
    opacity: 1;
}

.header-message-display small {
    display: block;
}

.header-message-display strong {
    font-weight: 600;
}

.secret-message {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    font-weight: 500;
    font-family: Arial, sans-serif;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 12px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
}
.reading-controls {
    display: none;
    align-items: center;
    gap: 0;
    background: linear-gradient(90deg,
        hsla(calc(var(--ecosystem-hue, 230) + 0), 25%, 96%, 1),
        hsla(calc(var(--ecosystem-hue, 230) + 20), 30%, 94%, 1),
        hsla(calc(var(--ecosystem-hue, 230) + 40), 25%, 92%, 1),
        hsla(calc(var(--ecosystem-hue, 230) + 60), 20%, 94%, 1));
    border: 1px solid #000;
    overflow: hidden;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
.reading-controls.active {
    display: flex;
}
.reader-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 16px;
    background: transparent;
    border: none;
    border-right: 1px solid #000;
    cursor: pointer;
    transition: all 0.15s ease;
    outline: none;
}
.reader-nav-btn:last-child {
    border-right: none;
}
.reader-nav-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.05);
}
.reader-nav-btn:active:not(:disabled) {
    background: rgba(0, 0, 0, 0.1);
}
.reader-nav-btn:disabled {
    cursor: not-allowed;
    opacity: 0.3;
}
.has-fixed-header {
    padding-top: 56px;
}

/* ============================================================================
   MEDIUM LAPTOPS (769px - 1200px) - Common laptop sizes like 1366px
   ============================================================================ */
@media (min-width: 769px) and (max-width: 1200px) {
    .header-unified {
        padding: 0 20px;
        gap: 24px;
    }
    
    .header-unified .header-logo {
        height: 48px;
    }
    
    .header-center-group {
        gap: 12px;
    }
    
    .header-message-display {
        width: 200px;
        font-size: 0.75rem;
        height: 32px;
        line-height: 1.25;
    }
    
    .errantson-helper {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
    }
    
    .errantson-helper img {
        width: 28px;
        height: 28px;
    }
    
    .nav-dropdown-trigger {
        padding: 6px 12px;
        font-size: 13px;
        height: 36px;
        gap: 6px;
    }
    
    .nav-current-icon {
        font-size: 14px;
    }
    
    .nav-current-label {
        font-size: 13px;
    }
    
    .reader-header {
        min-height: 52px;
        padding: 10px 16px;
    }
}

/* Specific adjustments for small laptops (769-1000px) */
@media (min-width: 769px) and (max-width: 1000px) {
    .header-unified {
        padding: 0 16px;
        gap: 16px;
    }
    
    .header-unified .header-logo {
        height: 44px;
    }
    
    .header-message-display {
        width: 160px;
        font-size: 0.7rem;
    }
    
    .nav-dropdown-trigger {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .nav-current-label {
        font-size: 12px;
    }
    
    /* Hide non-essential elements on small laptops */
    .beta-notice {
        display: none;
    }
}

@media (max-width: 768px) {
    .header-unified .logo-link,
    .beta-notice,
    .desktop-nav,
    .header-center-group {
        display: none;
    }
    
    .reader-header {
        width: 100%;
        left: 0;
        right: 0;
        padding: 0;
        height: 50px;
        align-items: stretch; /* let children fill full bar height */
    }
    .header-unified {
        padding: 0;
        width: 100%;
        height: 100%;
        align-items: stretch;
    }
    .mobile-nav {
        display: flex;
        align-items: stretch;
        width: 100%;
        padding: 0;
    }

    .mobile-center-group {
        display: none;
    }

    .mobile-message-display {
        display: none;
    }

    /* Logo hidden on mobile — tabs fill the full bar */
    .mobile-logo-link { display: none; }

    /* === Mobile Tab Navigation === */
    .mobile-tab-nav {
        display: flex;
        align-items: stretch;
        flex: 1;
        width: 100%;
        height: 100%;
    }

    .mobile-tab-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        gap: 3px;
        padding: 0 4px;
        min-width: 0;
        color: rgba(255, 255, 255, 0.45);
        text-decoration: none;
        /* Top border is the selection indicator — transparent by default */
        border-top: 3px solid transparent;
        transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-tab-item svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    /* Me tab: circular avatar replaces the cloud SVG */
    .mobile-tab-item .me-tab-avatar {
        display: block;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        object-fit: cover;
        border: 1.5px solid rgba(255,255,255,0.4);
        flex-shrink: 0;
    }

    .mobile-tab-item .me-tab-name {
        font-size: 8px;
        font-weight: 600;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        white-space: nowrap;
        line-height: 1;
    }

    .mobile-tab-item span {
        font-size: 8px;
        font-weight: 600;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        white-space: nowrap;
        line-height: 1;
    }

    /* Active: bright top edge + gradient fill that fades down — like light
       catching the top face of a physical selector. No border-radius anywhere. */
    .mobile-tab-item.active {
        color: #fff;
        border-top-color: rgba(255, 255, 255, 0.95);
        background: linear-gradient(
            to bottom,
            rgba(255, 255, 255, 0.22) 0%,
            rgba(255, 255, 255, 0.07) 55%,
            transparent 100%
        );
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
    }

    .mobile-tab-item:active {
        background: rgba(255, 255, 255, 0.07);
    }

    /* Remove old hamburger and dropdown — replaced by tab nav */
    .hamburger-btn { display: none !important; }
    .mobile-menu { display: none !important; }

    /* === Errantson FAB (injected into body by header.js on mobile) === */
    .errantson-fab {
        position: fixed;
        bottom: 22px;
        right: 18px;
        width: 52px;
        height: 52px;
        min-width: 52px;
        min-height: 52px;
        border-radius: 50%;
        border: 2px solid var(--reverie-core-color, #734ba1);
        background: rgba(255, 255, 255, 0.96);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18), 0 1px 4px rgba(0, 0, 0, 0.1);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: visible;
        padding: 0;
        z-index: 9500;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .errantson-fab:active {
        transform: scale(0.92);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    }

    .errantson-fab img {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        object-fit: cover;
        pointer-events: none;
    }

    /* Stronger pulse for unread messages on FAB */
    .errantson-fab.has-unread .helper-pulse,
    .errantson-fab.needs-attention .helper-pulse {
        animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
        border-color: var(--reverie-core-color, #734ba1);
    }

    .has-fixed-header {
        padding-top: 66px;
    }
}