:root {
    /* Color Palette - Vibrant Brand Colors */
    --os-blue: #0058eb;
    /* benji2timez Primary Blue */
    --os-light-gray: rgba(255, 255, 255, 0.1);
    --os-dark-gray: rgba(255, 255, 255, 0.4);
    --os-window-bg: rgba(255, 255, 255, 0.15);
    --os-text: #000000;
    --os-border: rgba(255, 255, 255, 0.3);
    --os-highlight: rgba(255, 255, 255, 0.4);

    /* Typography */
    /* Using Andale Mono per user request */
    --font-ui: 'Andale Mono', monospace;

    /* Layout */
    --menu-height: 28px;
    --window-chrome-height: 24px;
}

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

body {
    background-color: var(--os-blue);
    color: var(--os-text);
    font-family: var(--font-ui);
    font-size: 14px;
    text-transform: lowercase;
    overflow: hidden;
    /* Prevent scrolling on the desktop */
    user-select: none;
    /* Prevent accidental text selection while dragging */
    -webkit-font-smoothing: antialiased;
}

/* --- Grain Texture overlay --- */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* --- Screen Transitions --- */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    /* 300ms smooth fade per requirements */
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- Login Screen --- */
#login-screen {
    background-color: var(--os-blue);
    /* Match brand blue */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    /* Behind grain, above everything else initially */
}

.bios-dialog {
    background-color: var(--os-blue);
    /* Exact match to desktop */
    padding: 4px;
    box-shadow: 16px 16px 0px #000000;
    /* Distinct block drop shadow */
    width: 480px;
    transform: scale(0.65);
    /* Make window another 15% smaller */
}

.bios-dialog-inner {
    border: 2px solid #000000;
    /* Inner black outline to match text */
    padding: 32px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bios-label {
    color: #000000;
    font-family: var(--font-ui);
    /* Serifs match the screenshot */
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 0.5px;
    margin-right: 16px;
}

.bios-input-group {
    display: flex;
    align-items: center;
    color: #000000;
    font-size: 20px;
    font-weight: bold;
    font-family: var(--font-ui);
}

.bios-bracket {
    margin: 0 4px;
}

.bios-input-group input {
    background-color: transparent;
    color: #000000;
    border: none;
    outline: none;
    width: 140px;
    font-family: var(--font-ui);
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 4px;
    padding: 4px 0;
    transition: transform 0.1s ease;
}

.bios-submit-btn {
    background: transparent;
    border: 1px solid #000000;
    color: #000000;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: bold;
    padding: 2px 8px;
    margin-left: 6px;
    cursor: pointer;
    box-shadow: 2px 2px 0 #000000;
    transition: transform 0.1s ease, background 0.1s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.bios-submit-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #000000;
    background: rgba(0, 0, 0, 0.15);
}

/* Subtle shake animation for error */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

.bios-input-group input.error {
    animation: shake 0.3s ease-in-out;
}

/* --- Menu Bar --- */
.menu-bar {
    height: var(--menu-height);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border-bottom: 1px solid #000000;
    color: #000000;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 500;
    position: relative;
    z-index: 900;
}

.menu-left,
.menu-right {
    display: flex;
    gap: 16px;
    align-items: center;
}

.menu-item {
    cursor: default;
}

.menu-item.logo {
    font-weight: 600;
    margin-right: 8px;
    cursor: pointer;
}

.menu-item.logo:active {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

/* --- Dropdown Menu --- */
.menu-dropdown-container {
    position: relative;
    display: flex;
    align-items: center;
}

.menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid #000000;
    border-radius: 0;
    padding: 8px 0;
    min-width: 120px;
    box-shadow: 3px 3px 0 #000000;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.menu-dropdown.hidden {
    display: none;
}

.dropdown-item {
    padding: 6px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* --- Desktop Elements --- */
.desktop-footer {
    position: absolute;
    bottom: 24px;
    left: 0;
    width: 100%;
    text-align: center;
    color: #000000;
    font-size: 14px;
    font-weight: bold;
    z-index: 50;
    pointer-events: none;
}

/* --- Window System --- */
#window-container {
    position: absolute;
    top: var(--menu-height);
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    /* Let clicks pass through to desktop if no window */
}

.os-window {
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(32px) saturate(150%);
    -webkit-backdrop-filter: blur(32px) saturate(150%);
    border: 1px solid #000000;
    border-radius: 0;
    box-shadow: 3px 3px 0 #000000;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    /* Re-enable clicks for windows */

    /* Animation rules: no bounce, 200ms ease */
    transition: opacity 0.2s ease, transform 0.2s ease;
    opacity: 1;
    overflow: hidden;
    resize: both;
}

/* Inactive window state */
.os-window.inactive {
    opacity: 0.9;
    /* Slight dimming per spec */
}

.os-window.inactive .window-titlebar {
    opacity: 0.8;
}

/* -------------------------------------
 * VINTAGE MAC OS ZOOM RECTANGLES & CRT BOOT
 * ------------------------------------- */

.zoom-rects-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99999;
}

.mac-zoom-rect {
    position: fixed;
    border: 1.5px solid #000000;
    background: transparent;
    pointer-events: none;
    box-sizing: border-box;
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4);
    will-change: left, top, width, height, opacity;
}

/* CRT & Venetian Shutter Boot FX */
.crt-boot-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9998;
    display: flex;
    flex-direction: column;
}

.crt-shutter-slat {
    flex: 1;
    background: #000000;
    transform-origin: top center;
    animation: shutterOpen 0.36s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes shutterOpen {
    0% {
        transform: scaleY(1);
    }
    100% {
        transform: scaleY(0);
    }
}

.crt-phosphor-beam {
    position: fixed;
    top: 50%;
    left: 0;
    width: 100vw;
    height: 4px;
    background: #ffffff;
    box-shadow: 0 0 20px 6px #ffffff, 0 0 40px 10px var(--os-blue);
    transform: translateY(-50%) scaleX(0);
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    animation: phosphorBeam 0.38s ease-out forwards;
}

@keyframes phosphorBeam {
    0% {
        transform: translateY(-50%) scaleX(0) scaleY(1);
        opacity: 1;
    }
    30% {
        transform: translateY(-50%) scaleX(1) scaleY(2);
        opacity: 0.95;
    }
    60% {
        transform: translateY(-50%) scaleX(1) scaleY(80);
        opacity: 0.5;
    }
    100% {
        transform: translateY(-50%) scaleX(1) scaleY(300);
        opacity: 0;
    }
}

/* -------------------------------------
 * WINDOW & FOLDER ANIMATIONS
 * ------------------------------------- */

/* Hero Entrance on Initial Boot */
@keyframes windowHeroBoot {
    0% {
        opacity: 0;
        transform: scale(0.65) translateY(28px);
        filter: blur(6px);
    }
    65% {
        opacity: 1;
        transform: scale(1.02) translateY(-4px);
        filter: blur(0px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0px);
    }
}

.os-window.os-window-hero-boot {
    animation: windowHeroBoot 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Standard Window Pop In */
@keyframes windowPopIn {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(14px);
    }
    70% {
        transform: scale(1.015) translateY(-2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.os-window.os-window-opening {
    animation: windowPopIn 0.26s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Window Pop Out (Closing) */
@keyframes windowPopOut {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.88) translateY(12px);
    }
}

.os-window.os-window-closing {
    animation: windowPopOut 0.18s cubic-bezier(0.4, 0, 1, 1) forwards !important;
    pointer-events: none !important;
}

/* Window Re-open / Already Open Attention Pulse */
@keyframes windowReopenPulse {
    0% {
        transform: scale(1);
    }
    35% {
        transform: scale(1.025);
        box-shadow: 0 0 0 2px #000, 5px 5px 0 #000;
    }
    70% {
        transform: scale(0.99);
    }
    100% {
        transform: scale(1);
        box-shadow: 3px 3px 0 #000;
    }
}

.os-window.os-window-reopen {
    animation: windowReopenPulse 0.32s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Folder Icon Selection & Opening Feedback */
.os-icon {
    transition: transform 0.15s ease;
}

.os-icon:hover .os-icon-graphic {
    transform: scale(1.04);
}

.os-icon:active .os-icon-graphic,
.os-icon.os-icon-opening .os-icon-graphic {
    transform: scale(0.93);
    background: rgba(0, 0, 0, 0.8) !important;
    box-shadow: 1px 1px 0 #000 !important;
}

.os-icon:active .os-icon-graphic svg,
.os-icon.os-icon-opening .os-icon-graphic svg {
    filter: invert(1);
}

.os-icon:active .os-icon-label,
.os-icon.os-icon-opening .os-icon-label {
    background: #000 !important;
    color: #fff !important;
}

/* Staggered Item Cascades inside Windows & Folders */
@keyframes itemCascadeIn {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.icon-view .os-icon {
    animation: itemCascadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.icon-view .os-icon:nth-child(1) { animation-delay: 0.04s; }
.icon-view .os-icon:nth-child(2) { animation-delay: 0.08s; }
.icon-view .os-icon:nth-child(3) { animation-delay: 0.12s; }
.icon-view .os-icon:nth-child(4) { animation-delay: 0.16s; }
.icon-view .os-icon:nth-child(5) { animation-delay: 0.20s; }
.icon-view .os-icon:nth-child(6) { animation-delay: 0.24s; }
.icon-view .os-icon:nth-child(7) { animation-delay: 0.28s; }
.icon-view .os-icon:nth-child(8) { animation-delay: 0.32s; }
.icon-view .os-icon:nth-child(n+9) { animation-delay: 0.36s; }

/* List Row Micro-Entrance */
.list-view-container .list-row {
    animation: itemCascadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.list-view-container .list-row:nth-child(1) { animation-delay: 0.03s; }
.list-view-container .list-row:nth-child(2) { animation-delay: 0.06s; }
.list-view-container .list-row:nth-child(3) { animation-delay: 0.09s; }
.list-view-container .list-row:nth-child(4) { animation-delay: 0.12s; }
.list-view-container .list-row:nth-child(5) { animation-delay: 0.15s; }
.list-view-container .list-row:nth-child(n+6) { animation-delay: 0.18s; }


.window-titlebar {
    height: 24px;
    background-image: repeating-linear-gradient(0deg,
            transparent,
            transparent 1px,
            rgba(0, 0, 0, 0.5) 1px,
            rgba(0, 0, 0, 0.5) 2px);
    border-bottom: 1px solid #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
}

.window-titlebar:active {
    cursor: grabbing;
}

.window-title {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #000000;
    color: #000000;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    z-index: 2;
    height: 18px;
    line-height: 16px;
    display: inline-block;
}

.window-close-btn {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 13px;
    height: 13px;
    border-radius: 0;
    background-color: #ffffff;
    border: 1px solid #000000;
    cursor: pointer;
    z-index: 2;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.window-close-btn::before {
    content: '';
    display: block;
    width: 5px;
    height: 5px;
    border: 1px solid #000;
}

.window-close-btn:active {
    background-color: rgba(255, 255, 255, 1);
}

.window-content {
    flex: 1;
    overflow: auto;
    background: transparent;
    padding: 16px;
    position: relative;
    color: #ffffff;
}

/* Hide scrollbar for clean aesthetic but keep functionality */
.window-content::-webkit-scrollbar {
    width: 12px;
}

.window-content::-webkit-scrollbar-track {
    background: var(--os-light-gray);
    border-left: 1px solid var(--os-border);
}

.window-content::-webkit-scrollbar-thumb {
    background-color: var(--os-dark-gray);
    border: 1px solid var(--os-border);
}

/* Content Layouts inside windows (Level 2 & Level 3 previews) */
.icon-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 32px 16px;
    padding: 24px;
    justify-items: center;
    align-items: start;
}

.os-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    width: 100%;
}

.os-icon-graphic {
    width: 60px;
    height: 50px;
    border-radius: 0;
    border: 1px solid #000000;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    box-shadow: 2px 2px 0 #000000;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
}

.os-icon-graphic::before {
    content: '';
    width: 24px;
    height: 12px;
    border: 1px solid #000000;
    border-bottom: none;
    border-radius: 0;
    position: absolute;
    top: -12px;
    left: -1px;
    background: inherit;
}

.os-icon-graphic::after {
    display: none;
}

.os-icon-label {
    background-color: transparent;
    color: #000000;
    padding: 2px 4px;
    border-radius: 0;
    font-size: 11px;
    text-align: center;
    text-shadow: none;
    transition: background-color 0.2s ease;
}

.os-icon:active .os-icon-graphic {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0.95);
}

.os-icon:active .os-icon-label {
    background-color: rgba(255, 255, 255, 0.2);
}

/* --- Level 2 View: Project Grid --- */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 16px;
    padding: 12px;
}

.project-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.project-thumb img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 0;
    border: 1px solid #000000;
    box-shadow: 2px 2px 0 #000000;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.project-thumb:active img {
    filter: brightness(0.8);
    transform: scale(0.97);
}

.project-label {
    font-size: 11px;
    text-align: center;
    background-color: transparent;
    color: #000000;
    padding: 2px 4px;
    border-radius: 0;
    text-shadow: none;
    transition: background-color 0.2s ease;
}

.project-thumb:active .project-label {
    background-color: rgba(255, 255, 255, 0.2);
}

/* --- Level 3 View: Project Detail (Photo Grid / Viewer) --- */
.photo-gallery.grid-view {
    display: grid;
    grid-template-columns: repeat(var(--gallery-cols, 3), 1fr);
    gap: 2px;
    /* Tight grid like iPhone photos */
    padding: 2px;
}

.gallery-desc {
    grid-column: 1 / -1;
    padding: 12px;
    font-family: var(--font-ui);
    font-size: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid transparent;
    /* spacing */
}

.gallery-item {
    aspect-ratio: 1;
    overflow: hidden;
    background: #000;
}

.photo-gallery img.gallery-photo,
.photo-gallery video.gallery-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: filter 0.2s ease;
}

.photo-gallery img.gallery-photo:hover,
.photo-gallery video.gallery-photo:hover {
    filter: brightness(0.9);
}

/* Expanded Photo Viewer inside window */
.photo-viewer {
    position: absolute;
    top: 24px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000000;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.photo-viewer-bar {
    height: 32px;
    background: #111111;
    border-bottom: 1px solid #333333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    font-size: 11px;
    color: #888888;
    font-family: var(--font-ui);
    user-select: none;
    flex-shrink: 0;
    z-index: 10;
}

.photo-viewer-counter {
    color: #cccccc;
    letter-spacing: 1px;
    font-weight: bold;
}

.photo-viewer-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.photo-bar-btn {
    background: transparent;
    border: 1px solid #555555;
    color: #eeeeee;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.photo-bar-btn:active {
    background: #333333;
    border-color: #888888;
}

.photo-bar-btn.close-btn {
    border-color: #777777;
    background: rgba(255, 255, 255, 0.1);
}

.photo-viewer-content {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: auto;
    touch-action: pan-y;
}

.photo-viewer-content img,
.photo-viewer-content video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-in;
}

.photo-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 56px;
    background: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 24px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.photo-nav-arrow:active {
    background: rgba(0, 0, 0, 0.85);
}

.photo-nav-arrow.prev {
    left: 0;
    border-left: none;
    border-radius: 0 4px 4px 0;
}

.photo-nav-arrow.next {
    right: 0;
    border-right: none;
    border-radius: 4px 0 0 4px;
}

/* Menu Bar Clock Ticker */
.clock-ticker {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
}

.clock-sep {
    opacity: 0.5;
}

/* List View Styles */
.list-view-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: transparent;
    overflow-y: auto;
    padding: 8px 0;
}

.list-row {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    cursor: pointer;
    color: var(--os-text);
    transition: background 0.1s, color 0.1s;
    user-select: none;
}

.list-row:hover {
    background: #0058d0;
    color: #ffffff;
}

.list-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.list-label {
    flex: 1;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.list-arrow {
    font-size: 14px;
    opacity: 0.5;
    margin-left: 8px;
    font-weight: bold;
}

.list-row:hover .list-arrow {
    opacity: 1;
}

.list-row:hover .list-icon-wrapper svg path {
    fill: #ffffff;
}

/* --- Spinners --- */
@keyframes pixel-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.pixel-spinner {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    /* Beachball conic gradient in 6 shades of blue */
    background: conic-gradient(#cce4ff 0deg 60deg,
            #99caff 60deg 120deg,
            #66b0ff 120deg 180deg,
            #3395ff 180deg 240deg,
            #007aff 240deg 300deg,
            #005ecc 300deg 360deg);
    animation: pixel-spin 1.2s infinite steps(12);
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -12px;
    margin-left: -12px;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* -------------------------------------
 * RETRO VINTAGE PAGER (B-96 PAGER)
 * ------------------------------------- */
.pager-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px;
    font-family: var(--font-ui);
    user-select: none;
    width: 100%;
    box-sizing: border-box;
}

.pager-device {
    width: 100%;
    max-width: 380px;
    background: linear-gradient(145deg, #2b2b2b, #181818);
    border: 2px solid #444;
    border-radius: 14px;
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -2px 0 rgba(0, 0, 0, 0.6),
        0 8px 24px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease;
}

.pager-device::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: repeating-linear-gradient(90deg, #333, #333 4px, #1a1a1a 4px, #1a1a1a 8px);
    opacity: 0.7;
}

.pager-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px 6px;
}

.pager-brand {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #888;
    text-transform: uppercase;
}

.pager-indicators {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pager-sound-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 2px;
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.1s ease;
}

.pager-sound-toggle:hover {
    opacity: 1;
    transform: scale(1.1);
}

.pager-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2a2a2a;
    border: 1px solid #111;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.pager-led.green {
    background: #00ff66;
    box-shadow: 0 0 8px #00ff66;
}

.pager-led.amber {
    background: #ffb300;
    box-shadow: 0 0 8px #ffb300;
}

.pager-led.blink {
    animation: ledPulse 0.25s infinite alternate;
}

@keyframes ledPulse {
    0% { opacity: 0.2; }
    100% { opacity: 1; }
}

.pager-screen-bezel {
    margin: 4px 14px 12px;
    background: #0d140e;
    border-radius: 8px;
    padding: 7px;
    box-shadow: 
        inset 0 3px 6px rgba(0, 0, 0, 0.9),
        0 1px 0 rgba(255, 255, 255, 0.1);
}

.pager-screen {
    background: #8fae83;
    border-radius: 4px;
    padding: 8px 10px;
    color: #152b14;
    text-shadow: 0 0 1px rgba(21, 43, 20, 0.4);
    font-family: var(--font-ui);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.15);
}

.pager-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.03),
        rgba(0, 0, 0, 0.03) 2px,
        transparent 2px,
        transparent 4px
    );
}

.pager-screen-status {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    font-weight: bold;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(21, 43, 20, 0.25);
    padding-bottom: 4px;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.pager-screen-body {
    min-height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.pager-screen-line1 {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 2px;
    text-transform: uppercase;
}

.pager-screen-line2 {
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 1.5px;
    min-height: 18px;
}

.pager-keypad {
    margin: 0 14px 10px;
}

.pager-keys-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.pager-btn {
    height: 38px;
    background: linear-gradient(180deg, #383838 0%, #262626 100%);
    color: #e5e5e5;
    border: 1px solid #444;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        0 3px 0 #141414,
        0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.05s ease, background 0.1s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pager-btn:hover {
    background: linear-gradient(180deg, #444 0%, #2e2e2e 100%);
    color: #fff;
}

.pager-btn:active {
    transform: translateY(2px);
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 1px 0 #141414;
}

.pager-btn-fn {
    background: linear-gradient(180deg, #3d2525 0%, #2a1515 100%);
    color: #ff9999;
    border-color: #553333;
    box-shadow: 
        inset 0 1px 0 rgba(255, 150, 150, 0.15),
        0 3px 0 #150909;
}

.pager-btn-fn:hover {
    background: linear-gradient(180deg, #4d2e2e 0%, #361c1c 100%);
    color: #ffb3b3;
}

.pager-btn-send {
    background: linear-gradient(180deg, #1b3d24 0%, #102616 100%);
    color: #7aff9b;
    border-color: #2b5e38;
    box-shadow: 
        inset 0 1px 0 rgba(120, 255, 155, 0.15),
        0 3px 0 #09170e;
}

.pager-btn-send:hover {
    background: linear-gradient(180deg, #234f2f 0%, #15331e 100%);
    color: #99ffb3;
}

.pager-bottom-controls {
    margin: 0 14px 14px;
}

.pager-quick-send {
    width: 100%;
    height: 32px;
    background: #1c1c1c;
    color: #888;
    border: 1px dashed #444;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.15s ease;
}

.pager-quick-send:hover {
    background: #252525;
    color: #ddd;
    border-color: #666;
}

.pager-quick-send:active {
    transform: translateY(1px);
}

/* Vibration Animation */
@keyframes pagerVibrate {
    0% { transform: translate(0, 0) rotate(0deg); }
    20% { transform: translate(-2px, 2px) rotate(-0.5deg); }
    40% { transform: translate(2px, -1px) rotate(0.5deg); }
    60% { transform: translate(-1px, 2px) rotate(0deg); }
    80% { transform: translate(2px, 1px) rotate(-0.5deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

.pager-vibrate {
    animation: pagerVibrate 0.1s linear infinite;
}

/* Thermal Printout Slip */
.pager-slip {
    width: 100%;
    max-width: 380px;
    margin-top: 10px;
    background: #faf8f0;
    color: #1a1a1a;
    border: 1px dashed #999;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    position: relative;
    animation: slipSlideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pager-slip.hidden {
    display: none !important;
}

@keyframes slipSlideDown {
    0% {
        opacity: 0;
        transform: translateY(-20px);
        max-height: 0;
    }
    100% {
        opacity: 1;
        transform: translateY(0);
        max-height: 400px;
    }
}

.pager-slip-content {
    padding: 14px 16px;
    font-family: var(--font-ui);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pager-slip-header {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    font-weight: bold;
    border-bottom: 1px solid #ccc;
    padding-bottom: 6px;
    letter-spacing: 0.5px;
    color: #555;
    text-transform: uppercase;
}

.pager-slip-message {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slip-meta {
    font-size: 10px;
    color: #666;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.slip-email-box {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 10px;
}

.slip-email-label {
    font-size: 9px;
    color: #777;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.slip-email-val {
    font-size: 14px;
    font-weight: bold;
    color: #000;
    letter-spacing: 0.5px;
    user-select: text;
}

.pager-slip-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.slip-action-btn {
    flex: 1;
    height: 32px;
    border: 1px solid #333;
    background: #fff;
    color: #111;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 2px 0 #bbb;
    transition: all 0.1s ease;
    text-transform: uppercase;
    box-sizing: border-box;
}

.slip-action-btn:hover {
    background: #f0f0f0;
    box-shadow: 0 1px 0 #bbb;
    transform: translateY(1px);
}

.slip-action-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

.slip-action-primary {
    background: #111;
    color: #fff;
    border-color: #000;
    box-shadow: 0 2px 0 #444;
}

.slip-action-primary:hover {
    background: #222;
    color: #fff;
}

.slip-action-reset {
    flex: 0 0 65px;
    background: #e5e5e5;
    color: #555;
    border-color: #bbb;
}

.slip-action-btn.copied {
    background: #28a745 !important;
    color: #fff !important;
    border-color: #1e7e34 !important;
}

/* -------------------------------------
 * MOBILE OPTIMIZATION
 * ------------------------------------- */

@media (max-width: 768px) {
    :root {
        --menu-height: calc(44px + env(safe-area-inset-top, 0px));
    }

    /* Prevent mobile overflow */
    html, body {
        overflow: hidden;
        width: 100%;
        height: 100%;
        height: 100dvh;
    }

    .screen {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
    }

    /* Menu Bar */
    .menu-bar {
        padding: env(safe-area-inset-top, 0px) 10px 0 10px;
        height: var(--menu-height);
        min-height: 44px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .menu-left {
        gap: 10px;
        align-items: center;
    }

    .menu-item {
        padding: 4px 6px;
        font-size: 11px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .menu-item.logo {
        font-size: 12px;
        font-weight: 700;
        letter-spacing: -0.2px;
        margin-right: 0;
        white-space: nowrap;
    }

    /* Clock Ticker: Hide extra timezones on narrow screens to prevent wrapping */
    .clock-ticker {
        font-size: 11px;
        gap: 4px;
        white-space: nowrap;
    }

    #clock-min,
    #clock-ny,
    .clock-sep {
        display: none !important;
    }

    /* Menu Dropdowns */
    .menu-dropdown {
        padding: 6px 0;
        box-shadow: 4px 4px 0 #000000;
    }

    .dropdown-item {
        padding: 10px 16px;
        font-size: 12px;
        -webkit-tap-highlight-color: transparent;
    }

    /* Full-width / Centered Search Dropdown on Mobile */
    #search-dropdown {
        position: fixed !important;
        top: calc(var(--menu-height) + 6px) !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        max-width: 380px !important;
        margin: 0 auto !important;
        padding: 12px !important;
        box-shadow: 6px 6px 0 #000000 !important;
        z-index: 2000 !important;
    }

    #search-input {
        font-size: 16px !important; /* Prevents iOS auto-zoom */
        padding: 8px 10px !important;
    }

    /* BIOS Login Screen */
    #login-screen {
        padding: 16px;
        box-sizing: border-box;
    }

    .bios-dialog {
        width: 100% !important;
        max-width: 330px !important;
        transform: none !important;
        box-shadow: 8px 8px 0px #000000 !important;
        margin: auto;
    }

    .bios-dialog-inner {
        padding: 24px 16px !important;
        flex-direction: column !important;
        gap: 14px !important;
        text-align: center;
    }

    .bios-label {
        font-size: 15px !important;
        margin-right: 0 !important;
    }

    .bios-input-group {
        font-size: 18px !important;
        justify-content: center;
    }

    .bios-input-group input {
        width: 120px !important;
        font-size: 18px !important; /* >= 16px prevents iOS auto-zoom */
    }

    .bios-submit-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 34px;
        min-height: 34px;
    }

    /* Window Container */
    #window-container {
        top: var(--menu-height);
        bottom: env(safe-area-inset-bottom, 0px);
    }

    /* OS Windows on Mobile */
    .os-window {
        max-width: calc(100vw - 16px) !important;
        max-height: calc(100dvh - var(--menu-height) - 24px - env(safe-area-inset-bottom, 0px)) !important;
        resize: none !important; /* Disable desktop resize grip on touchscreens */
        box-shadow: 3px 3px 0 #000000;
    }

    .window-titlebar {
        height: 38px;
        flex-shrink: 0;
        padding-left: 40px;
        padding-right: 40px;
        touch-action: none;
    }

    .window-close-btn {
        position: absolute;
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        width: 18px;
        height: 18px;
        z-index: 3;
    }

    /* 44px Generous touch target for window close button */
    .window-close-btn::after {
        content: '';
        position: absolute;
        top: -12px;
        left: -12px;
        right: -12px;
        bottom: -12px;
    }

    .window-title {
        font-size: 12px;
        letter-spacing: 0.5px;
        padding: 0 8px;
        height: 20px;
        line-height: 18px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .window-content {
        padding: 12px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Folder / Icon grid on mobile */
    .icon-view {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        gap: 20px 10px;
        padding: 16px 8px;
    }

    .os-icon-graphic {
        width: 52px;
        height: 42px;
    }

    .os-icon-label {
        font-size: 11px;
    }

    /* Project Grid on Mobile */
    .project-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
        padding: 8px;
    }

    .project-label {
        font-size: 10px;
    }

    /* Project Detail (Photo Gallery) */
    .photo-gallery.grid-view {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 2px;
    }

    /* Pager adjustments for mobile */
    .pager-wrapper {
        padding: 4px 0 12px;
    }

    .pager-device {
        max-width: 100%;
        border-radius: 12px;
    }

    .pager-screen-bezel {
        margin: 4px 10px 10px;
        padding: 6px;
    }

    .pager-screen {
        padding: 6px 8px;
    }

    .pager-screen-line1 {
        font-size: 10px;
    }

    .pager-screen-line2 {
        font-size: 12px;
    }

    .pager-keypad {
        margin: 0 10px 10px;
    }

    .pager-keys-grid {
        gap: 6px;
    }

    .pager-btn {
        height: 42px; /* Ergonomic touch target for thumbs */
        font-size: 15px;
    }

    .pager-quick-send {
        height: 38px;
        font-size: 11px;
    }

    .pager-slip {
        max-width: 100%;
    }

    .pager-slip-actions {
        flex-direction: column;
        gap: 8px;
    }

    .slip-action-btn {
        height: 40px;
        font-size: 12px;
        width: 100%;
    }

    .slip-action-reset {
        flex: auto;
    }

    /* Photo Viewer Lightbox on Mobile */
    .photo-viewer {
        top: 38px !important;
    }

    .photo-viewer-bar {
        height: 38px;
        padding: 0 8px;
    }

    .photo-bar-btn {
        padding: 4px 8px;
        font-size: 10px;
    }

    .photo-nav-arrow {
        width: 32px;
        height: 52px;
        font-size: 20px;
    }

    /* Desktop Footer on Mobile */
    .desktop-footer {
        font-size: 10px;
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        padding: 0 8px;
    }
}