:root {
    /* Color Palette - Light Mode (Vercel/Linear inspired) */
    --bg-main: #FAFAFA;
    --bg-surface: #FFFFFF;
    --bg-hover: #F3F4F6;
    --border-color: #EAEAEA;
    
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    
    --accent-blue: #0070F3;
    --accent-blue-hover: #0060d3;
    --accent-blue-alpha: rgba(0, 112, 243, 0.1);
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.025);
    
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

.dark {
    /* Color Palette - Dark Mode */
    --bg-main: #000000;
    --bg-surface: #0A0A0A;
    --bg-hover: #1A1A1A;
    --border-color: #222222;
    
    --text-primary: #EDEDED;
    --text-secondary: #A1A1AA;
    --text-muted: #52525B;
    
    --accent-blue: #3291FF;
    --accent-blue-hover: #0070F3;
    --accent-blue-alpha: rgba(50, 145, 255, 0.1);
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

/* Base Reset & Typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: var(--radius-lg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Utilities */
.hidden { display: none !important; }

/* Layouts */
.full-height {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: transparent;
    color: var(--text-primary);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: #FFFFFF;
    box-shadow: 0 2px 4px rgba(0, 112, 243, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-blue-hover);
    box-shadow: 0 4px 8px rgba(0, 112, 243, 0.3);
}

.btn-secondary {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-icon {
    padding: 6px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
}

.btn-icon:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-alpha);
}

/* Auth View */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 24px;
}

.auth-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    width: 100%;
    max-width: 400px;
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header svg {
    color: var(--accent-blue);
    margin-bottom: 12px;
}

.auth-header h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* App View Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-header {
    height: 56px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

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

.current-email-badge {
    font-size: 14px;
    font-weight: 500;
    padding: 4px 10px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    align-items: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Dashboard Grid */
.app-body {
    display: grid;
    grid-template-columns: 320px 1fr;
    flex: 1;
    overflow: hidden;
}

/* Sidebar / Message List */
.app-sidebar {
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-search {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-search .form-input {
    background-color: var(--bg-main);
}

.message-list-container {
    flex: 1;
    overflow-y: auto;
}

.message-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

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

.message-item.active {
    background-color: var(--accent-blue-alpha);
    border-left: 3px solid var(--accent-blue);
    padding-left: 13px; /* Adjust for border */
}

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

.msg-subject {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Viewer */
.app-main {
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.email-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: #FFFFFF; /* Ensure email content has white bg */
}

.email-text {
    font-family: monospace;
    white-space: pre-wrap;
    line-height: 1.6;
}

.viewer-padding {
    padding: 32px;
    overflow-y: auto;
    height: 100%;
}

/* Empty States & Skeletons */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    height: 100%;
}

.empty-state svg {
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
}

.empty-state span {
    font-size: 12px;
    margin-top: 4px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.skeleton-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.skeleton-line {
    height: 14px;
    background-color: var(--border-color);
    border-radius: 4px;
    margin-bottom: 8px;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.skeleton-line.title { width: 70%; }
.skeleton-line.sub { width: 40%; margin-bottom: 0; }

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    transform: translateY(20px);
    opacity: 0;
    transition: all var(--transition-normal);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success svg { color: #10B981; }
.toast-error svg { color: #EF4444; }
.toast-info svg { color: var(--accent-blue); }

/* Utility Animations */
.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-body {
        grid-template-columns: 1fr;
    }
    .mobile-hidden {
        display: none !important;
    }
    .app-sidebar {
        border-right: none;
    }
    .viewer-padding {
        padding: 16px;
    }
}