/* ==========================================================================
   MAC DECK - CSS STYLESHEET
   Steam Deck Inspired Glassmorphism, Dark Metallic Palette & Neon Accents
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-darker: #0d1117;
    --bg-dark: #151a22;
    --bg-card: rgba(26, 32, 44, 0.7);
    --bg-glass: rgba(22, 28, 38, 0.55);
    --bg-active: rgba(255, 255, 255, 0.1);
    
    /* Neon Accents */
    --accent-blue: #00c0f0;
    --accent-blue-glow: rgba(0, 192, 240, 0.4);
    --accent-orange: #ff5c00;
    --accent-orange-glow: rgba(255, 92, 0, 0.4);
    --accent-purple: #8b5cf6;
    
    /* Text Colors */
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Reset & Basic Setup */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-darker);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Typography */
h1, h2, h3, .brand {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Global Helper Classes */
.hidden {
    display: none !important;
}

.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
}

/* Buttons */
.btn {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #008cb0);
    color: #fff;
    box-shadow: 0 0 15px var(--accent-blue-glow);
}
.btn-primary:active {
    transform: scale(0.95);
    box-shadow: 0 0 5px var(--accent-blue-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-secondary:active {
    background: rgba(255, 255, 255, 0.15);
}

.btn-dark {
    background: #1e293b;
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.05);
}
.btn-dark:active {
    background: #0f172a;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
}
.btn-xs {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
}
.btn-block {
    display: flex;
    width: 100%;
}

/* Glow Background effect */
.glow-bg {
    position: absolute;
    top: -15%;
    left: -10%;
    width: 120%;
    height: 130%;
    background: 
        radial-gradient(circle at 10% 20%, rgba(0, 192, 240, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 92, 0, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.05) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ==========================================================================
   DESKTOP LANDING VIEW
   ========================================================================== */

#desktop-view {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10;
    position: relative;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

.desktop-card {
    width: 100%;
    max-width: 1000px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.desktop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 20px;
}

.logo {
    font-size: 2.2rem;
    font-weight: 800;
    color: #fff;
}
.logo-accent, .brand-accent {
    color: var(--accent-orange);
    background: linear-gradient(135deg, var(--accent-orange), #ff8700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    padding: 6px 14px;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.status-connected {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.05);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.pulse-green {
    background-color: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.6; }
}

.desktop-grid {
    display: grid;
    grid-template-columns: 1.1fr 1.3fr;
    gap: 40px;
}

/* QR Section */
.qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.qr-section h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}
.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 25px;
}

.qr-wrapper {
    padding: 20px;
    background: #fff; /* white background necessary for QR contrasts */
    border-radius: 12px;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 240px;
    height: 240px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}
#qr-code {
    width: 100% !important;
    height: 100% !important;
}
#qr-fallback {
    color: #111;
    font-size: 0.85rem;
}

.ip-address-box {
    width: 100%;
}
.ip-address-box .label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.url-input-group {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 6px 6px 6px 12px;
    align-items: center;
    justify-content: space-between;
}
.url-input-group code {
    font-family: monospace;
    font-size: 0.95rem;
    color: var(--accent-blue);
    word-break: break-all;
}

/* Info Section */
.info-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card-panel {
    padding: 20px;
}
.card-panel h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setup-steps {
    list-style-position: inside;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}
.setup-steps li {
    margin-bottom: 8px;
}

.permission-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
    padding: 12px;
    border-radius: 8px;
    margin-top: 10px;
}
.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 500;
}
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--text-muted);
}
.status-dot.active {
    background-color: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}
.status-dot.inactive {
    background-color: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.permission-instructions {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    font-size: 0.85rem;
}
.permission-instructions ol {
    margin-top: 6px;
    padding-left: 16px;
}
.permission-instructions li {
    margin-bottom: 4px;
}

/* Stats panel */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
.stat-item {
    display: flex;
    flex-direction: column;
    background: rgba(0,0,0,0.15);
    padding: 10px 14px;
    border-radius: 8px;
}
.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.stat-val {
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
}

.desktop-footer {
    margin-top: 30px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========================================================================
   MOBILE CONTROLLER VIEW
   ========================================================================== */

#mobile-view {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100dvh;
    background-color: var(--bg-darker);
    overflow: hidden;
    position: relative;
}

/* Mobile status bar */
.mobile-status-bar {
    height: 48px;
    background: #11141b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
}
.mobile-status-bar .brand {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}
.active-app-badge {
    margin-left: 10px;
    font-size: 0.75rem;
    background: rgba(0, 192, 240, 0.15);
    border: 1px solid rgba(0, 192, 240, 0.3);
    color: var(--accent-blue);
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

.mobile-status-bar .right-section {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.stat-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.04);
    padding: 3px 8px;
    border-radius: 50px;
}
.time-clock {
    font-weight: 600;
    color: var(--text-primary);
}

/* Content Area */
.mobile-content {
    flex: 1;
    position: relative;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 72px; /* nav bar height spacing */
}

/* Panels */
.panel-section {
    display: none;
    height: 100%;
    padding: 16px;
    animation: fadeIn 0.2s ease-out;
}
.panel-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.section-title-bar h2 {
    font-size: 1.4rem;
}

/* Library carousel */
.library-carousel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    max-height: calc(100dvh - 170px);
    overflow-y: auto;
    padding-bottom: 20px;
}

.app-card {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    cursor: pointer;
    transition: var(--transition-bounce);
    position: relative;
    overflow: hidden;
}
.app-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at 50% 10%, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}
.app-card:active {
    transform: scale(0.95);
    background: var(--accent-blue-glow);
    border-color: var(--accent-blue);
}
.app-card .icon-wrapper {
    font-size: 2.8rem;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}
.app-card .app-name {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}
.app-card .delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 22px;
    height: 22px;
    background: rgba(239, 68, 68, 0.8);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 0.8rem;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    display: none; /* toggled in edit mode */
}
.library-carousel.edit-mode .app-card .delete-btn {
    display: block;
}

/* Trackpad View */
#panel-trackpad {
    padding: 12px;
    height: 100%;
}
.trackpad-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 12px;
}
#virtual-trackpad {
    flex: 1;
    min-height: 220px;
    border-radius: 20px;
    position: relative;
    background: radial-gradient(circle at center, rgba(30, 41, 59, 0.4) 0%, rgba(15, 23, 42, 0.6) 100%);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none; /* Disable native browser touch behaviors */
}
.trackpad-helper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-align: center;
    pointer-events: none;
    padding: 20px;
}
.trackpad-helper .icon {
    font-size: 2rem;
    opacity: 0.5;
}
.trackpad-helper .text {
    font-size: 0.8rem;
    max-width: 200px;
    line-height: 1.4;
}

.trackpad-controls {
    display: flex;
    align-items: center;
}
.sensitivity-slider-box {
    display: flex;
    width: 100%;
    align-items: center;
    background: var(--bg-card);
    padding: 10px 14px;
    border-radius: 8px;
    gap: 12px;
}
.sensitivity-slider-box label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.sensitivity-slider-box input[type="range"] {
    flex: 1;
    accent-color: var(--accent-blue);
}
.sensitivity-slider-box span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-blue);
    min-width: 35px;
}

.trackpad-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    height: 52px;
}
.track-btn {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.8));
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}
.track-btn:active {
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

/* Keyboard Panel */
#panel-keyboard {
    height: 100%;
}
.keyboard-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
}

.keyboard-input-wrapper {
    display: flex;
    background: var(--bg-glass);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 4px;
    align-items: center;
}
#keyboard-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    padding: 10px;
    font-size: 0.95rem;
}
#keyboard-input::placeholder {
    color: var(--text-muted);
}

.modifier-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.key-modifier {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-secondary);
    padding: 10px 0;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.key-modifier.active {
    background: var(--accent-orange);
    color: white;
    box-shadow: 0 0 10px var(--accent-orange-glow);
    border-color: var(--accent-orange);
}

.action-keys-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.key-action {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-primary);
    padding: 10px 0;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
}
.key-action:active {
    background: var(--accent-blue-glow);
    border-color: var(--accent-blue);
}

.keyboard-layout-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 12px;
}

/* Direction pad */
.nav-direction-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    aspect-ratio: 1 / 1;
    padding: 8px;
    gap: 4px;
}
.nav-arrow {
    padding: 0 !important;
}
.nav-arrow.up { grid-column: 2; grid-row: 1; }
.nav-arrow.left { grid-column: 1; grid-row: 2; }
.nav-arrow.down { grid-column: 2; grid-row: 3; }
.nav-arrow.right { grid-column: 3; grid-row: 2; }

/* Macros */
.macro-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
}
.macro-btn {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(139, 92, 246, 0.05));
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: #c084fc;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
}
.macro-btn:active {
    background: rgba(139, 92, 246, 0.4);
    transform: scale(0.96);
}

/* ==========================================================================
   GAME CONTROLLER OVERLAY
   ========================================================================== */

#panel-controller {
    padding: 8px;
    overflow: hidden;
}

.controller-overlay-container {
    display: flex;
    justify-content: space-between;
    height: 100%;
    align-items: center;
    padding: 10px 0;
}

.controller-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 35%;
}

.controller-center {
    width: 30%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

/* Virtual D-pad */
.virtual-dpad {
    position: relative;
    width: 110px;
    height: 110px;
    background: #0f141c;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    border: 2px solid #232a35;
}
.dpad-btn {
    position: absolute;
    background: #28313e;
    border: 1px solid #1a202a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.05);
}
.dpad-btn:active {
    background: var(--accent-blue);
}
.dpad-center {
    position: absolute;
    top: 36px;
    left: 36px;
    width: 38px;
    height: 38px;
    background: #28313e;
    z-index: 2;
}

.dpad-up {
    top: 6px;
    left: 36px;
    width: 38px;
    height: 36px;
    border-radius: 6px 6px 0 0;
}
.dpad-down {
    bottom: 6px;
    left: 36px;
    width: 38px;
    height: 36px;
    border-radius: 0 0 6px 6px;
}
.dpad-left {
    top: 36px;
    left: 6px;
    width: 36px;
    height: 38px;
    border-radius: 6px 0 0 6px;
}
.dpad-right {
    top: 36px;
    right: 6px;
    width: 36px;
    height: 38px;
    border-radius: 0 6px 6px 0;
}

.arrow-shape {
    border: 6px solid transparent;
    display: block;
}
.dpad-up .arrow-shape { border-bottom-color: #9cb3c9; border-top: none; }
.dpad-down .arrow-shape { border-top-color: #9cb3c9; border-bottom: none; }
.dpad-left .arrow-shape { border-right-color: #9cb3c9; border-left: none; }
.dpad-right .arrow-shape { border-left-color: #9cb3c9; border-right: none; }

.dpad-btn:active .arrow-shape {
    border-color: transparent;
}
.dpad-up:active .arrow-shape { border-bottom-color: white; }
.dpad-down:active .arrow-shape { border-top-color: white; }
.dpad-left:active .arrow-shape { border-right-color: white; }
.dpad-right:active .arrow-shape { border-left-color: white; }

/* ABXY Face Buttons */
.face-buttons {
    position: relative;
    width: 110px;
    height: 110px;
    background: #0f141c;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    border: 2px solid #232a35;
}
.face-btn {
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    cursor: pointer;
}
.action-desc {
    font-size: 0.45rem;
    font-weight: 500;
    opacity: 0.8;
}

/* Gamepad colored buttons */
.btn-y { top: 6px; left: 39px; background: #eab308; } /* Yellow */
.btn-x { top: 39px; left: 6px; background: #3b82f6; } /* Blue */
.btn-b { top: 39px; right: 6px; background: #ef4444; } /* Red */
.btn-a { bottom: 6px; left: 39px; background: #22c55e; } /* Green */

.face-btn:active {
    transform: scale(0.9);
    filter: brightness(1.2);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Joysticks */
.joystick-pad {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}
.joystick-knob {
    width: 44px;
    height: 44px;
    background: radial-gradient(circle at 35% 35%, #475569 0%, #1e293b 80%);
    border: 2px solid #0f172a;
    border-radius: 50%;
    position: absolute;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.05s ease;
}
.joystick-label {
    position: absolute;
    bottom: -18px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* Bumpers / Shoulder */
.shoulder-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
}
.shoulder-btn {
    flex: 1;
    font-size: 0.75rem;
    padding: 10px 0;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.select-start-buttons {
    display: flex;
    gap: 12px;
}
.select-btn, .start-btn {
    font-size: 0.7rem;
    padding: 6px 12px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   SYSTEM & MEDIA PANEL
   ========================================================================== */

.settings-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-card {
    padding: 16px;
}
.settings-card h3 {
    font-size: 1.1rem;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.media-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}
.media-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-primary);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.media-btn:active {
    background: var(--accent-blue-glow);
    border-color: var(--accent-blue);
}
.media-btn.play-pause {
    width: 60px;
    height: 60px;
    background: var(--accent-orange);
    border: none;
    box-shadow: 0 0 15px var(--accent-orange-glow);
}
.media-btn.play-pause:active {
    transform: scale(0.95);
}

.slider-group {
    margin-bottom: 16px;
}
.slider-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}
.slider-wrapper input[type="range"] {
    flex: 1;
    accent-color: var(--accent-orange);
}
.slider-val {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

/* System Action buttons grid */
.system-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.sys-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-primary);
    padding: 14px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-align: center;
}
.sys-btn:active {
    background: var(--accent-blue-glow);
    border-color: var(--accent-blue);
}
.sys-btn.warning {
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.2);
}
.sys-btn.warning:active {
    background: rgba(239, 68, 68, 0.2);
}

.conn-status-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 10px;
}
.conn-status-row:last-child {
    margin-bottom: 0;
}
.text-green {
    color: #10b981;
    font-weight: 600;
}

/* ==========================================================================
   NAVIGATION BAR
   ========================================================================== */

.mobile-nav-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #11141b;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 100;
}
.nav-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.nav-item .icon {
    font-size: 1.3rem;
    margin-bottom: 2px;
    transition: var(--transition-bounce);
}
.nav-item .label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.nav-item.active {
    color: var(--accent-blue);
}
.nav-item.active .icon {
    transform: scale(1.15) translateY(-2px);
    filter: drop-shadow(0 0 5px var(--accent-blue-glow));
}

/* ==========================================================================
   MANAGE LIBRARY MODAL
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.25s ease-out;
}

.modal-content {
    width: 100%;
    max-width: 450px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.modal-header h2 {
    font-size: 1.25rem;
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.modal-tabs {
    display: flex;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 16px;
}
.modal-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 0;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
}
.modal-tab-btn.active {
    background: var(--bg-active);
    color: white;
}

.modal-tab-panel {
    display: none;
}
.modal-tab-panel.active {
    display: block;
}

.search-box {
    margin-bottom: 12px;
}
.search-box input {
    width: 100%;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.06);
    padding: 10px 14px;
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    outline: none;
}
.search-box input::placeholder {
    color: var(--text-muted);
}

.apps-list-container {
    max-height: 250px;
    overflow-y: auto;
    border-radius: 8px;
    background: rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.04);
}
.loading-spinner {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.app-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    cursor: pointer;
}
.app-list-item:last-child {
    border-bottom: none;
}
.app-list-item:active {
    background: rgba(255,255,255,0.05);
}
.app-list-item .app-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.app-list-item .app-icon-placeholder {
    font-size: 1.3rem;
}
.app-list-item .app-title-text {
    font-size: 0.85rem;
    font-weight: 500;
}
.app-list-item .add-indicator {
    font-size: 0.85rem;
    color: var(--accent-blue);
    font-weight: 600;
}

/* Custom form styles */
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}
.form-group input {
    width: 100%;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.06);
    padding: 10px 12px;
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    outline: none;
}
.form-group input::placeholder {
    color: var(--text-muted);
}

/* ==========================================================================
   DESKTOP MAC SIMULATION (WEB DEMO MODE)
   ========================================================================== */

/* Grid and Panel adjustments */
@media (min-width: 1024px) {
    .desktop-grid {
        display: grid;
        grid-template-columns: 340px 1fr;
        gap: 24px;
        align-items: start;
    }
}

.desktop-screen-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
}

#simulated-mac-desktop {
    position: relative;
    width: 100%;
    aspect-ratio: 16/10;
    max-height: 520px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b3c66 0%, #15162b 100%);
    background-image: 
        radial-gradient(circle at 80% 20%, rgba(244, 63, 94, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 10% 80%, rgba(59, 130, 246, 0.2) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cpath d='M0 0 L100 100 M100 0 L0 100' stroke='rgba(255,255,255,0.015)' stroke-width='1'/%3E%3C/svg%3E");
    border: 5px solid #202632;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
}

/* Simulated menu bar */
.sim-menu-bar {
    height: 24px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: white;
    font-size: 11px;
    font-weight: 500;
    gap: 14px;
    z-index: 100;
}
.sim-menu-bar .apple-logo {
    font-size: 14px;
    font-weight: 700;
    margin-right: 4px;
    cursor: default;
}
.sim-menu-bar .menu-item {
    opacity: 0.85;
    cursor: default;
}
.sim-menu-bar .menu-item.active {
    font-weight: 700;
    opacity: 1;
}
.sim-menu-right {
    margin-left: auto;
    display: flex;
    gap: 12px;
}

/* Desktop wallpaper working area */
.sim-desktop-area {
    position: relative;
    flex: 1;
    overflow: hidden;
}

/* Mouse pointer representation */
#sim-mouse-cursor {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    pointer-events: none;
    z-index: 9999;
    transform: translate(0, 0);
    transition: transform 0.04s ease-out; /* smooth lag for realism */
}

/* macOS simulated window structure */
.sim-window {
    position: absolute;
    width: 320px;
    height: 220px;
    background: rgba(20, 26, 38, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
    z-index: 10;
    transition: box-shadow 0.2s;
}
.sim-window.active {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 1px 1px rgba(255, 255, 255, 0.2);
    z-index: 20;
}

.win-titlebar {
    height: 28px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    padding: 0 10px;
    position: relative;
    cursor: move;
}

.win-buttons {
    display: flex;
    gap: 6px;
    margin-right: 12px;
}
.win-buttons span {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
    cursor: pointer;
}
.win-close-btn { background: #ff5f56; }
.win-minimize-btn { background: #ffbd2e; }
.win-zoom-btn { background: #27c93f; }

.win-title {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    margin: 0 auto;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.win-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: auto;
    color: white;
}

/* Safari theme content */
.safari-navbar {
    height: 30px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    padding: 0 8px;
}
.safari-navbar .address-bar {
    background: rgba(0,0,0,0.3);
    width: 100%;
    height: 20px;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.04);
}
.safari-body {
    padding: 14px;
    font-size: 0.8rem;
    line-height: 1.4;
}
.safari-body h2 {
    font-size: 1.1rem;
    margin-bottom: 6px;
    color: white;
}

/* Spotify theme content */
.spotify-theme {
    background: #121212;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: row;
}
.spotify-sidebar {
    width: 80px;
    background: #000;
    font-size: 9px;
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #b3b3b3;
}
.spotify-sidebar div {
    cursor: pointer;
    text-align: center;
}
.spotify-sidebar div:hover {
    color: white;
}
.spotify-main {
    flex: 1;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.spotify-main h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #b3b3b3;
    margin-bottom: 8px;
}
.album-art {
    width: 50px;
    height: 50px;
    background: var(--accent-orange);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 8px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.4);
}
.spotify-main h3 {
    font-size: 0.85rem;
    margin-bottom: 6px;
}
.player-controls {
    display: flex;
    gap: 12px;
    font-size: 1.1rem;
    margin-top: 4px;
}

/* VS Code theme content */
.vscode-theme {
    background: #1e1e1e;
}
.code-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.editor-header {
    background: #252526;
    height: 22px;
    font-size: 10px;
    color: #858585;
    padding-left: 10px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #1e1e1e;
}
.code-editor textarea {
    flex: 1;
    background: transparent;
    border: none;
    resize: none;
    color: #9cdcfe;
    font-family: monospace;
    font-size: 11px;
    padding: 10px;
    outline: none;
}

/* macOS dock bar */
.sim-dock {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 6px 12px;
    display: flex;
    gap: 14px;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.dock-item {
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.dock-item:hover {
    transform: scale(1.3) translateY(-6px);
}

/* Hidden visual states helper */
.demo-only.hidden, .local-only.hidden {
    display: none !important;
}

/* macOS HUD overlay (Volume/Brightness) */
#sim-hud-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 130px;
    height: 130px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 1000;
    box-shadow: 0 15px 35px rgba(0,0,0,0.6);
    pointer-events: none;
    transition: opacity 0.2s ease-out;
}
#sim-hud-overlay.hidden {
    opacity: 0;
    display: none !important;
}
.hud-icon {
    font-size: 2.5rem;
}
.hud-bar-wrapper {
    width: 90px;
    height: 5px;
    background: rgba(255,255,255,0.22);
    border-radius: 3px;
    overflow: hidden;
}
.hud-bar-fill {
    height: 100%;
    background: white;
    border-radius: 3px;
    width: 0%;
}

/* Media Queries & Console Overlays */


/* ==========================================================================
   LANDSCAPE CONSOLE OVERLAY FRAME
   ========================================================================== */

.console-wrapper {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--bg-darker);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 192, 240, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 92, 0, 0.05) 0%, transparent 40%),
        linear-gradient(45deg, #11151d 25%, transparent 25%),
        linear-gradient(-45deg, #11151d 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #11151d 75%),
        linear-gradient(-45deg, transparent 75%, #11151d 75%);
    background-size: 100% 100%, 100% 100%, 8px 8px, 8px 8px, 8px 8px, 8px 8px;
}

.console-handle {
    width: 130px;
    height: 100%;
    background: linear-gradient(180deg, #1e2530 0%, #12161f 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    padding: 20px 0;
    box-shadow: inset 0 1px 3px rgba(255,255,255,0.05), 0 0 15px rgba(0,0,0,0.5);
    z-index: 10;
    position: relative;
}

.left-handle {
    border-right: 1px solid rgba(255,255,255,0.05);
    border-radius: 0 16px 16px 0;
    box-shadow: 5px 0 15px rgba(0,0,0,0.3);
}
.left-handle::after {
    content: '';
    position: absolute;
    top: 10%; right: 0; bottom: 10%; width: 2px;
    background: linear-gradient(to bottom, transparent, var(--accent-orange), transparent);
    box-shadow: 0 0 8px var(--accent-orange-glow);
}

.right-handle {
    border-left: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px 0 0 16px;
    box-shadow: -5px 0 15px rgba(0,0,0,0.3);
}
.right-handle::after {
    content: '';
    position: absolute;
    top: 10%; left: 0; bottom: 10%; width: 2px;
    background: linear-gradient(to bottom, transparent, var(--accent-orange), transparent);
    box-shadow: 0 0 8px var(--accent-orange-glow);
}

.console-screen-wrapper {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 4px solid #1c2330;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
    position: relative;
    overflow: hidden;
}

.dpad-wrapper, .face-buttons-wrapper {
    margin: 10px 0;
}

.joystick-container, .joystick-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.joystick-pad {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: #0d1117;
    border: 2px solid rgba(255,255,255,0.03);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 15px var(--accent-blue-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.joystick-pad::after {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    border-radius: 50%;
    border: 2px solid var(--accent-blue);
    opacity: 0.5;
    pointer-events: none;
    box-shadow: 0 0 10px var(--accent-blue-glow);
}

.bumper-trigger-group {
    width: 100%;
    padding: 0 10px;
}
.bumper-trigger-group button {
    width: 100%;
    background: linear-gradient(180deg, #374151, #1f2937);
    color: var(--text-secondary);
    border: 1px solid rgba(255,255,255,0.05);
    font-weight: 800;
    font-size: 0.75rem;
    padding: 8px 0;
    border-radius: 6px;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.1), 0 3px 5px rgba(0,0,0,0.3);
}
.bumper-trigger-group button:active {
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 0 10px var(--accent-blue-glow);
}

/* Landscape View specific adaptations */
@media (min-aspect-ratio: 1.25) {
    /* Hide the Gamepad tab icon on landscape since controllers are physically on the sides! */
    .mobile-nav-bar button[data-target="panel-controller"] {
        display: none !important;
    }
}

/* Portrait View specific overrides (Standard phone layout) */
@media (max-aspect-ratio: 1.25) {
    .console-handle {
        display: none !important;
    }
    .console-screen-wrapper {
        border: none;
        border-radius: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
    }
    .console-wrapper {
        background-image: none;
        background-color: var(--bg-darker);
    }
}

/* Desktop layout constraint fallback */
@media (min-width: 768px) {
    #mobile-view {
        max-width: 740px; /* widen to account for controller handles in preview */
        margin: 0 auto;
        border: 2px solid rgba(255,255,255,0.08);
        border-radius: 20px;
        box-shadow: 0 0 60px rgba(0,0,0,0.9);
    }
    .console-screen-wrapper {
        border-radius: 0;
    }
}
