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

body {
    font-family: 'Courier New', Courier, monospace;
    background: #001800;
    color: #0f0;
    overflow: hidden;
    height: 100vh;
    position: relative;
}

/* Initial black screen fade-in */
.page-fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 20000;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.8s ease-out;
}

.page-fade-overlay.fade-out {
    opacity: 0;
}

/* Boot screen */
.boot-screen {
    position: absolute;
    top: 80px;
    left: 80px;
    right: 80px;
    bottom: 100px;
    background: #001800;
    z-index: 100;
    padding: 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    color: #aaa;
    overflow: hidden;
    transition: opacity 0.5s ease-out;
    border: 3px solid #0f0;
    border-radius: 8px;
}

.boot-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.boot-screen pre {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.4;
}

.boot-screen .highlight {
    color: #0f0;
}

.boot-screen .white {
    color: #fff;
}

.crt-border-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 80px solid transparent;
    border-image-source: url('screenborder.png');
    border-image-slice: 200 95 fill;
    border-image-width: 80px;
    border-image-repeat: stretch;
    pointer-events: none;
    z-index: 9999;
}

.container {
    position: absolute;
    top: 80px;
    left: 80px;
    right: 80px;
    bottom:100px;
    background: transparent;
    border: 3px solid #0f0;
    border-radius: 8px;
    box-shadow: 
        0 0 20px rgba(0, 255, 0, 0.3),
        inset 0 0 50px rgba(0, 255, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}

.terminal-header {
    background: transparent;
    border-bottom: 2px solid #0f0;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 0 5px #0f0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-links {
    display: flex;
    gap: 12px;
    font-size: 12px;
    font-weight: normal;
}

.header-link {
    color: #0f0;
    text-decoration: none;
    padding: 4px 8px;
    border: 1px solid #0f0;
    border-radius: 3px;
    transition: all 0.2s;
    text-shadow: 0 0 5px #0f0;
}

.header-link:hover {
    background: #0f0;
    color: #001800;
    box-shadow: 0 0 10px #0f0;
}

.terminal-title {
    letter-spacing: 2px;
}

.system-time {
    font-size: 12px;
    opacity: 0.8;
}

#terminal {
    flex: 1;
    padding: 5px 10px;
    overflow: hidden;
}

.xterm {
    height: 100%;
    padding: 0;
}

.xterm-viewport {
    background: transparent !important;
}

.xterm-screen {
    cursor: text;
}

/* Hide xterm cursor completely */
.xterm-cursor-layer {
    display: none !important;
}

/* Inline terminal input */
.terminal-inline-input {
    position: absolute;
    background: transparent;
    border: none;
    outline: none;
    color: #0f0;
    font-family: 'Courier New', Courier, monospace;
    font-size: inherit;
    padding: 0;
    margin: 0;
    caret-color: #0f0;
    text-shadow: 0 0 3px #0f0;
    z-index: 10;
    min-width: 50%;
    max-width: 80%;
    pointer-events: auto;
}

/* Clickable commands in terminal */
.xterm-screen a,
.xterm .xterm-link-layer a {
    color: #0f0 !important;
    text-decoration: underline !important;
    cursor: pointer !important;
    text-shadow: 0 0 5px #0f0;
}

.xterm-screen a:hover,
.xterm .xterm-link-layer a:hover {
    color: #0ff !important;
    text-shadow: 0 0 8px #0ff !important;
}

.terminal-inline-input::placeholder {
    color: rgba(0, 255, 0, 0.3);
}

.mention-suggestions {
    position: absolute;
    z-index: 11;
    display: flex;
    gap: 6px;
    max-width: 85%;
    padding: 1px 4px;
    border: 1px solid rgba(0, 255, 0, 0.45);
    background: rgba(0, 24, 0, 0.92);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.mention-suggestion {
    color: #66ff66;
    opacity: 0.9;
}

.mention-suggestion.selected {
    color: #001800;
    background: #66ff66;
    padding: 0 2px;
}

.status-bar {
    background: transparent;
    border-top: 2px solid #0f0;
    padding: 6px 16px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    text-shadow: 0 0 3px #0f0;
}

.status-left {
    font-weight: bold;
}

.status-right {
    opacity: 0.8;
}

/* Quick command buttons */
.quick-commands {
    display: flex;
    gap: 8px;
    align-items: center;
}

.quick-cmd {
    background: transparent;
    color: #0f0;
    border: 1px solid #0f0;
    border-radius: 3px;
    padding: 2px 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    text-shadow: 0 0 3px #0f0;
}

.quick-cmd:hover {
    background: #0f0;
    color: #001800;
    box-shadow: 0 0 8px #0f0;
}

.quick-cmd:active {
    transform: scale(0.95);
}

/* CRT scanlines effect */
.container::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
                linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 2;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}

/* Subtle screen flicker */
@keyframes flicker {
    0% { opacity: 0.98; }
    50% { opacity: 1; }
    100% { opacity: 0.98; }
}

.container {
    animation: flicker 1s infinite;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .crt-border-overlay {
        border-width: 40px;
        border-image-width: 40px;
    }
    
    .container,
    .boot-screen {
        top: 40px;
        left: 40px;
        right: 40px;
        bottom: 50px;
        border-radius: 4px;
    }
    
    .terminal-header {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .header-links {
        gap: 8px;
        font-size: 10px;
    }
    
    .header-link {
        padding: 3px 6px;
    }
    
    .system-time {
        font-size: 10px;
    }
    
    .status-bar {
        padding: 4px 12px;
        font-size: 10px;
    }
    
    .quick-commands {
        gap: 6px;
    }
    
    .quick-cmd {
        padding: 2px 6px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .crt-border-overlay {
        border-width: 15px;
        border-image-width: 15px;
    }
    
    .container,
    .boot-screen {
        top: 15px;
        left: 15px;
        right: 15px;
        bottom: 20px;
        border-width: 2px;
    }
    
    .boot-screen {
        font-size: 10px;
        padding: 8px;
    }
    
    .terminal-header {
        padding: 4px 8px;
    }
    
    .terminal-title {
        letter-spacing: 0;
        font-size: 9px;
    }
    
    .header-left {
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }
    
    .header-links {
        gap: 4px;
        font-size: 8px;
    }
    
    .header-link {
        padding: 2px 4px;
    }
    
    .header-right {
        display: none;
    }
    
    .status-bar {
        padding: 3px 8px;
        font-size: 9px;
    }
    
    .status-right {
        display: none;
    }
    
    #terminal {
        padding: 3px 5px;
    }
    
    /* Prevent iOS auto-zoom on input focus */
    .terminal-inline-input {
        font-size: 16px;
    }
}

/* Very small screens - minimal border */
@media (max-width: 380px) {
    .crt-border-overlay {
        border-width: 8px;
        border-image-width: 8px;
    }
    
    .container,
    .boot-screen {
        top: 8px;
        left: 8px;
        right: 8px;
        bottom: 12px;
        border-width: 1px;
        border-radius: 4px;
    }
    
    .terminal-header {
        padding: 3px 6px;
    }
    
    .terminal-title {
        font-size: 8px;
    }
    
    .header-links {
        display: none;
    }
    
    .status-bar {
        padding: 2px 6px;
    }
}

/* Very skinny screens - no border at all */
@media (max-width: 350px) {
    .crt-border-overlay {
        display: none;
    }
    
    .container,
    .boot-screen {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        border: none;
    }
    
    .terminal-header {
        border-bottom: 1px solid #0f0;
    }
    
    .status-bar {
        border-top: 1px solid #0f0;
    }
}

/* Keyboard open on mobile - detected via JS */
body.keyboard-open .crt-border-overlay {
    display: none;
}

body.keyboard-open .container,
body.keyboard-open .boot-screen {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
    border: none;
}

body.keyboard-open .terminal-header {
    border-bottom: 1px solid #0f0;
    padding: 3px 8px;
}

body.keyboard-open .status-bar {
    border-top: 1px solid #0f0;
    padding: 3px 8px;
}

/* Small viewport (under 1280x720) - detected via JS */
body.small-viewport .crt-border-overlay {
    display: none;
}

body.small-viewport .container,
body.small-viewport .boot-screen {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
    border: none;
}

body.small-viewport .terminal-header {
    border-bottom: 1px solid #0f0;
}

body.small-viewport .status-bar {
    border-top: 1px solid #0f0;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #001800;
}

::-webkit-scrollbar-thumb {
    background: #0f0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0c0;
}
