:root {
    --white: #fff;
    --black: #000;
    --cosmos: #1c1c1c;
    --red: #aa2c2c;
    --green: #2caa2c;
    --font: "Helvetica Neue", -apple-system, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; -webkit-font-smoothing: antialiased; }
body { background: var(--cosmos); font-family: var(--font); color: var(--white); }
a { text-decoration: none; color: inherit; }
button { border: none; outline: none; background: none; cursor: pointer; font: inherit; }
input, textarea { outline: none; font: inherit; }
.hidden { display: none !important; }

/* Nav */
.topnavbar {
    padding: 25px;
    position: fixed;
    z-index: 999;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    color: var(--white);
}
.nav-user { display: flex; align-items: center; gap: 20px; font-size: 0.9em; }
.logoutbtn {
    color: var(--white);
    border: 1px solid var(--white);
    padding: 8px 16px;
    transition: all 0.2s;
}
.logoutbtn:hover { background: var(--white); color: var(--cosmos); }

/* Login */
.mainpagewrap { display: flex; position: absolute; height: 100%; width: 100%; }
.inputwindowwrap {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    background: var(--cosmos);
    padding: 25px;
    z-index: 1;
    min-width: 520px;
}
.animationwindowrap {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    min-height: 100%;
}
.inputwindow {
    min-width: 470px;
    max-width: 470px;
    display: flex;
    flex-direction: column;
    padding: 25px;
    background: var(--black);
}
.sectionheader { font-size: 1.8em; font-weight: 500; line-height: 88%; margin-bottom: 20px; }
.therexinput {
    color: var(--white);
    background: var(--black);
    border: 1px solid var(--white);
    font-size: 1.2em;
    font-weight: 500;
    width: 100%;
    padding: 20px;
}
.therexinput::placeholder { color: #666; }
.passwordinput { margin-top: -1px; }
.submitbutton {
    color: var(--cosmos);
    background: var(--white);
    font-size: 1.2em;
    font-weight: 500;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: -1px;
}
.submitbutton:hover { background: #dedede; }
.submitbutton:disabled { opacity: 0.5; cursor: not-allowed; }
.emailinput { display: flex; }
.ataddition {
    color: var(--white);
    background: var(--black);
    border: 1px solid var(--white);
    border-left: none;
    font-size: 1.2em;
    font-weight: 500;
    padding: 20px;
    white-space: nowrap;
}
.errorinfo { color: var(--red); font-size: 1em; font-weight: 500; margin-top: 20px; min-height: 1.2em; }
.successinfo { color: var(--green); font-size: 1em; font-weight: 500; margin-top: 20px; line-height: 1.4; }
.switchform { margin-top: 25px; color: #666; font-size: 0.9em; }
.switchform a { color: var(--white); text-decoration: underline; }

@media (max-width: 1024px) {
    .animationwindowrap { display: none; }
    .inputwindowwrap { min-width: 100%; }
}
@media (max-width: 768px) {
    .inputwindow { min-width: 100%; max-width: 100%; }
}

/* Inbox */
.inbox-container { display: flex; height: 100vh; padding-top: 78px; }
.sidebar {
    width: 220px;
    background: var(--black);
    border-right: 1px solid #333;
    padding: 20px;
    display: flex;
    flex-direction: column;
}
.compose-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 15px 20px;
    background: var(--white);
    color: var(--cosmos);
    font-weight: 500;
    margin-bottom: 30px;
}
.compose-btn:hover { background: #dedede; }
.folders { display: flex; flex-direction: column; gap: 5px; }
.folder-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
}
.folder-item:hover { background: #1c1c1c; }
.folder-item.active { background: var(--cosmos); }
.unread-badge {
    background: var(--white);
    color: var(--black);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    font-weight: 600;
}
.email-list {
    flex: 1;
    background: var(--cosmos);
    display: flex;
    flex-direction: column;
    min-width: 300px;
    max-width: 400px;
    border-right: 1px solid #333;
}
.email-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #333;
}
.email-list-header h2 { font-size: 1.2em; font-weight: 500; }
.refresh-btn { color: var(--white); padding: 8px; }
.refresh-btn:hover { opacity: 0.7; }
.emails { flex: 1; overflow-y: auto; }
.email-item {
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-bottom: 1px solid #333;
    cursor: pointer;
}
.email-item:hover { background: var(--black); }
.email-item.unread { border-left: 3px solid var(--white); }
.email-item .from { font-weight: 600; margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-item .subject { font-size: 0.95em; margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-item .preview { font-size: 0.85em; color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-item .date { font-size: 0.8em; color: #666; margin-top: 8px; }
.loading, .empty-state { padding: 40px; text-align: center; color: #666; }

.email-view { flex: 1; background: var(--black); display: flex; flex-direction: column; overflow: hidden; }
.email-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #333;
}
.back-btn { display: flex; align-items: center; gap: 10px; color: var(--white); font-size: 0.9em; }
.back-btn:hover { opacity: 0.7; }
.email-actions { display: flex; gap: 10px; }
.action-btn { color: var(--white); border: 1px solid #333; padding: 8px 16px; font-size: 0.9em; }
.action-btn:hover { background: #333; }
.action-btn.delete:hover { background: var(--red); border-color: var(--red); }
.email-content { flex: 1; padding: 30px; overflow-y: auto; }
.email-content .email-header { margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid #333; }
.email-content .email-subject { font-size: 1.5em; font-weight: 500; margin-bottom: 15px; }
.email-content .email-meta { font-size: 0.9em; color: #888; }
.email-content .email-meta span { display: block; margin-bottom: 5px; }
.email-body { line-height: 1.6; }

/* Email iframe for HTML content */
.email-iframe {
    width: 100%;
    min-height: 400px;
    border: none;
    background: #fff;
}
.email-text {
    white-space: pre-wrap;
    font-family: inherit;
    margin: 0;
    line-height: 1.6;
}

/* Compose */
.compose-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.compose-window {
    background: var(--black);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid #333;
}
.compose-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #333;
}
.compose-header h3 { font-size: 1.2em; font-weight: 500; }
.close-btn { color: var(--white); font-size: 1.5em; padding: 5px 10px; }
.close-btn:hover { opacity: 0.7; }
.compose-form { display: flex; flex-direction: column; flex: 1; }
.compose-input {
    background: var(--black);
    color: var(--white);
    border: none;
    border-bottom: 1px solid #333;
    padding: 15px 20px;
    font-size: 1em;
}
.compose-input::placeholder { color: #666; }
.compose-body {
    flex: 1;
    min-height: 200px;
    background: var(--black);
    color: var(--white);
    border: none;
    padding: 20px;
    font-size: 1em;
    resize: none;
}
.compose-body::placeholder { color: #666; }
.compose-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-top: 1px solid #333;
}
.compose-error { color: var(--red); font-size: 0.9em; }
.send-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--white);
    color: var(--cosmos);
    padding: 12px 25px;
    font-weight: 500;
}
.send-btn:hover { background: #dedede; }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--black); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

/* Mobile */
@media (max-width: 900px) {
    .sidebar { width: 60px; padding: 10px; }
    .compose-btn span, .folder-item span:first-child { display: none; }
    .compose-btn { justify-content: center; padding: 15px; }
    .email-list { min-width: 200px; max-width: none; flex: 1; }
}

@media (max-width: 768px) {
    .topnavbar { padding: 15px; }
    .inbox-container { padding-top: 60px; }
    
    .sidebar { width: 50px; padding: 8px; }
    .compose-btn { padding: 12px; margin-bottom: 15px; }
    .folder-item { padding: 10px; }
    .unread-badge { padding: 2px 6px; font-size: 0.7em; }
    
    .email-list { 
        min-width: 0;
        max-width: none;
        flex: 1;
        border-right: none;
    }
    
    /* Hide email list when viewing an email */
    .inbox-container.viewing-email .email-list {
        display: none;
    }
    
    .email-view {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
    }
    
    .email-view.hidden {
        display: none !important;
    }
    
    .email-content { padding: 15px; }
    .email-content .email-subject { font-size: 1.2em; }
    
    .compose-window { 
        max-width: 100%; 
        max-height: 100%;
        height: 100%;
        border: none;
    }
}
