:root {
    /* Default (Dark / Lights Out) */
    --bg-color: #000000;
    --border-color: #2f3336;
    --text-primary: #e7e9ea;
    --text-secondary: #71767b;
    --accent-color: #1d9bf0;
    --hover-bg: #16181c;
    --selected-bg: #1d1f23;
    --glass-bg: rgba(0, 0, 0, 0.65);

    --modal-bg: #000000;
    --modal-shadow: rgba(255, 255, 255, 0.1);

    --input-bg: #000000;
    --input-border: #333333;
    --input-focus: #1d9bf0;

    --btn-primary-bg: #e7e9ea;
    --btn-primary-text: #000000;

    --btn-danger-text: #f4212e;
    --btn-danger-border: #f4212e;
}

body.theme-dim {
    /* Dim (Dark Blue) */
    --bg-color: #15202b;
    --border-color: #38444d;
    --text-primary: #f7f9f9;
    --text-secondary: #8b98a5;
    --hover-bg: #1c2732;
    --selected-bg: #1e2c3a;
    --glass-bg: rgba(21, 32, 43, 0.65);

    --modal-bg: #15202b;
    --modal-shadow: rgba(0, 0, 0, 0.5);

    --input-bg: #15202b;
    --input-border: #38444d;

    --btn-primary-bg: #f7f9f9;
    --btn-primary-text: #15202b;
}

body.theme-light {
    /* Light (White) */
    --bg-color: #ffffff;
    --border-color: #eff3f4;
    --text-primary: #0f1419;
    --text-secondary: #536471;
    --hover-bg: #f7f9f9;
    --selected-bg: #eff3f4;
    --glass-bg: rgba(255, 255, 255, 0.85);

    --modal-bg: #ffffff;
    --modal-shadow: rgba(0, 0, 0, 0.1);

    --input-bg: #ffffff;
    --input-border: #cfd9de;

    --btn-primary-bg: #0f1419;
    --btn-primary-text: #ffffff;
}

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

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

svg {
    width: 24px;
    height: 24px;
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 275px 600px 1fr;
    height: 100%;
    max-width: 1920px;
    margin: 0 auto;
}

.sidebar,
.feed,
.detail {
    border-right: 1px solid var(--border-color);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.detail {
    border-right: none;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Headers */
.sidebar-header,
.feed-header,
.detail-header {
    flex-shrink: 0;
    background-color: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    height: 53px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Sidebar Settings Button */
.settings-btn {
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background-color: var(--hover-bg);
}

/* Search */
.search-container {
    margin-left: 16px;
    flex: 1;
}

#search-input {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 10px 20px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
}

#search-input:focus {
    border-color: var(--accent-color);
    background-color: var(--bg-color);
}

/* Lists */
.nav-list,
.email-list,
.email-content {
    flex: 1;
    overflow-y: auto;
}

.account-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--text-primary);
    transition: 0.2s;
}

.account-item:hover {
    background-color: var(--hover-bg);
}

.account-item.active {
    border-right: 2px solid var(--accent-color);
    background-color: var(--selected-bg);
}

.account-icon {
    width: 40px;
    height: 40px;
    background-color: var(--input-border);
    border-radius: 50%;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-primary);
}

/* Email Item */
.email-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: 0.2s;
}

.email-item:hover {
    background-color: var(--hover-bg);
}

.email-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.sender-name {
    font-weight: 700;
    color: var(--text-primary);
}

.email-subject {
    font-weight: 500;
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.email-preview {
    color: var(--text-secondary);
    font-size: 15px;
}

/* Detail */
.detail-scroll-container {
    padding: 20px;
}

.detail-subject {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 16px;
    line-height: 1.3;
    color: var(--text-primary);
}

.detail-meta-row {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.email-body-container {
    background: white;
    padding: 20px;
    border-radius: 16px;
    margin-top: 20px;
}

iframe {
    width: 100%;
    border: none;
    min-height: 400px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.twitter-style-modal {
    background-color: var(--modal-bg);
    border-radius: 16px;
    padding: 32px;
    width: 600px;
    max-width: 90vw;
    border: 1px solid var(--border-color);
    box-shadow: 0 0 15px var(--modal-shadow);
    display: flex;
    flex-direction: column;
}

#login-modal .twitter-style-modal {
    width: 350px;
    padding: 30px 40px;
    align-items: stretch;
}

.twitter-logo-header {
    margin-bottom: 20px;
    text-align: center;
}

/* Logo removed via HTML but class kept for structure if needed */

.twitter-modal-title {
    font-size: 31px;
    font-weight: 700;
    margin-bottom: 30px;
    color: var(--text-primary);
    text-align: center;
}

/* Floating Inputs */
.twitter-input-group {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
}

.twitter-input-group input {
    width: 100%;
    padding: 20px 10px 8px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 17px;
    outline: none;
}

.twitter-input-group input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px var(--accent-color);
}

.twitter-input-group label {
    position: absolute;
    left: 10px;
    top: 18px;
    color: var(--text-secondary);
    font-size: 17px;
    transition: 0.2s ease all;
    pointer-events: none;
}

.twitter-input-group input:focus~label,
.twitter-input-group input:not(:placeholder-shown)~label {
    top: 6px;
    font-size: 13px;
    color: var(--accent-color);
}

/* Buttons */
.twitter-btn-black {
    width: 100%;
    padding: 12px;
    border-radius: 9999px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-weight: 700;
    font-size: 16px;
    border: none;
    cursor: pointer;
    margin-top: 10px;
    transition: opacity 0.2s;
}

.twitter-btn-black:hover {
    opacity: 0.9;
}

/* Settings */
.settings-content {
    overflow-y: auto;
    max-height: 80vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.settings-list-group {
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.settings-list-group:last-child {
    border-bottom: none;
}

.settings-list-group h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.theme-options {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.theme-btn {
    flex: 1;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
}

.theme-btn:hover {
    background: var(--hover-bg);
    border-color: var(--accent-color);
}

.color-options {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
}

.twitter-btn-outline {
    width: 100%;
    padding: 12px;
    border-radius: 9999px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 700;
    cursor: pointer;
}

.twitter-btn-outline:hover {
    background: var(--hover-bg);
}

.twitter-btn-outline:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.twitter-btn-danger {
    width: 100%;
    padding: 12px;
    border-radius: 9999px;
    background: transparent;
    border: 1px solid var(--btn-danger-border);
    color: var(--btn-danger-text);
    font-weight: 700;
    cursor: pointer;
}

.twitter-btn-danger:hover {
    background: rgba(244, 33, 46, 0.1);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
}

/* Hover Effect with Accent Tint */
.account-item:hover,
.email-item:hover,
.settings-btn:hover {
    background-color: color-mix(in srgb, var(--accent-color), transparent 90%);
}

.account-item.active {
    background-color: color-mix(in srgb, var(--accent-color), transparent 90%);
    border-right: 2px solid var(--accent-color);
}

.error-msg {
    color: #f4212e;
    margin-top: 10px;
    font-size: 14px;
    min-height: 20px;
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 60px 1fr;
        overflow: hidden;
        /* Prevent horizontal scroll during anim */
        position: relative;
    }

    /* Condensed Sidebar */
    .sidebar-header {
        justify-content: center;
        padding: 0;
    }

    .sidebar-header h2,
    .account-info {
        display: none;
    }

    .settings-btn {
        margin: 0 auto;
        /* Center settings gear */
    }

    .account-item {
        justify-content: center;
        padding: 12px 0;
    }

    .account-icon {
        margin-right: 0;
    }

    /* Detail View Animation */
    .detail {
        display: flex !important;
        /* Always flex, translate handles visibility */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: var(--bg-color);
        z-index: 50;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: none;
    }

    /* Mobile State: Show Detail (Slide In) */
    body.show-detail .detail {
        transform: translateX(0);
    }

    /* Feed is always visible underneath, effectively hidden by z-index */
    body.show-detail .feed {
        /* display: none; - REMOVED to allow smooth transition over it */
    }

    /* Show Back Button */
    #mobile-back-btn {
        display: block !important;
    }

    /* Modals need to be higher than detail */
    .modal-overlay {
        z-index: 100;
    }

    .twitter-style-modal {
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-width: none;
        border: none;
    }

    .settings-content {
        max-height: 100vh;
    }
}