:root {
    /* DeeDe Mail — Signature Orange & Dark Theme */
    --bg-app: #070708;
    --bg-sidebar: #0f0f10;
    --bg-mail-list: #131416;
    --bg-reading: #16181c;
    --bg-card: #17171a;
    --bg-elevated: #1a1a1c;
    --bg-hover: rgba(255, 140, 0, 0.06);

    --primary: #ff8c00;
    --primary-light: #ffaa33;
    --primary-dark: #cc7000;
    --primary-glow: rgba(255, 140, 0, 0.25);
    --primary-subtle: rgba(255, 140, 0, 0.08);

    --accent: #ff6b00;

    --border: #2a2a2a;
    --border-bright: #333333;
    --glass-border: rgba(255, 255, 255, 0.06);

    --text-main: #ffffff;
    --text-accent: #ff8c00;
    --text-muted: #777777;
    --text-dim: #555555;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-xl: 32px;

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-muted);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #000;
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px var(--primary-glow);
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-bright);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    color: var(--primary);
    background: var(--primary-subtle);
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: var(--transition-slow);
    flex-shrink: 0;
    position: relative;
    z-index: 20;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-toggle {
    position: absolute;
    right: -11px;
    top: 28px;
    width: 22px;
    height: 22px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-bright);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 30;
    color: var(--text-dim);
    font-size: 10px;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #000;
    transform: scale(1.1);
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

.logo-area {
    height: 72px;
    display: flex;
    align-items: center;
    padding: 0 22px;
    overflow: hidden;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.sidebar.collapsed .logo-area {
    padding: 0 22px;
}

.logo-icon {
    min-width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-text {
    font-size: 17px;
    font-weight: 700;
    margin-left: 12px;
    color: var(--text-main);
    letter-spacing: -0.3px;
    opacity: 1;
    transition: var(--transition);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .compose-btn span {
    opacity: 0;
    pointer-events: none;
    width: 0;
    margin-left: 0;
    margin-right: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.15s ease, width 0.25s cubic-bezier(0.4, 0, 0.2, 1), margin 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item span,
.compose-btn span,
.logo-text {
    transition: opacity 0.15s ease, width 0.25s cubic-bezier(0.4, 0, 0.2, 1), margin 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.compose-area {
    padding: 18px 16px;
    display: flex;
    justify-content: center;
}

.compose-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #000;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    box-shadow: 0 4px 16px var(--primary-glow);
    position: relative;
}

.compose-btn i {
    position: absolute;
    left: 18px;
    font-size: 16px;
    flex-shrink: 0;
    transition: var(--transition);
}

.compose-btn span {
    margin-left: 0;
}

.compose-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--primary-glow);
}

.compose-btn::after {
    content: '✨';
    position: absolute;
    right: 14px;
    font-size: 12px;
    opacity: 0;
    transition: var(--transition);
}

.compose-btn:hover::after {
    opacity: 1;
    right: 14px;
}

.sidebar.collapsed .compose-area {
    padding: 18px 16px;
}

.sidebar.collapsed .compose-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
    margin: 0;
    gap: 0;
    flex-shrink: 0;
}

.sidebar.collapsed .compose-btn i {
    margin: 0 !important;
    font-size: 18px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.sidebar.collapsed .compose-btn span {
    margin-left: 0;
}

.nav-area {
    flex: 1;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.sidebar.collapsed .nav-area {
    padding: 10px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0 14px;
    height: 42px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.sidebar.collapsed .nav-item:hover {
    background: var(--bg-hover);
}

.nav-item i {
    position: absolute;
    left: 14px;
    font-size: 16px;
    display: flex;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.nav-ai-icon {
    position: absolute;
    left: 13px;
    width: 20px;
    height: 20px;
    object-fit: contain;
    transition: var(--transition);
    flex-shrink: 0;
    opacity: 0.55;
}

.nav-ai-icon:hover {
    opacity: 0.85;
}

.sidebar.collapsed .nav-ai-icon {
    left: 24px;
    width: 22px;
    height: 22px;
}

.nav-item.active .nav-ai-icon {
    opacity: 1;
}

.nav-item span {
    margin-left: 34px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--primary-light);
}

.nav-item.active {
    background: var(--primary-subtle);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar.collapsed .nav-item i {
    left: 25px;
    font-size: 18px;
}

.sidebar.collapsed .nav-item.active::before {
    display: none;
}

/* --- MAIN CONTENT --- */
.main-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- TOPBAR --- */
.topbar {
    height: 68px;
    display: flex;
    align-items: center;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-app);
    backdrop-filter: blur(12px);
}

.search-container {
    flex: 1;
    display: flex;
    justify-content: center;
}

.search-box {
    width: 100%;
    max-width: 560px;
    background: var(--bg-card);
    height: 40px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    padding: 0 18px;
    gap: 10px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    flex: 1;
    color: var(--text-main);
    font-size: 13.5px;
}

.search-box input::placeholder {
    color: var(--text-dim);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px 5px 5px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
}

.profile-trigger:hover {
    background: var(--bg-elevated);
    border-color: var(--border-bright);
}

.profile-trigger::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 24px;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border: 2px solid var(--bg-card);
    border-radius: 50%;
    z-index: 1;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #ff5500, var(--primary-light));
    background-size: 200% 200%;
    animation: avatarShimmer 3s ease-in-out infinite;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #000;
    position: relative;
}

@keyframes avatarShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* --- MAIL LAYOUT --- */
.mail-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* List Pane */
.mail-list-pane {
    width: 380px;
    min-width: 380px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg-mail-list);
}

.mail-list-header {
    padding: 18px 22px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.mail-row {
    padding: 16px 22px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
    margin: 0;
    position: relative;
}

.mail-row::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: var(--transition);
}

.mail-row:hover {
    background: var(--bg-hover);
}

.mail-row.active {
    background: rgba(255,140,0,0.1);
    border-left: 3px solid var(--primary);
    position: relative;
}

.mail-row.active .mail-row-sender {
    color: var(--primary-light);
}

.mail-row.active .mail-row-subject {
    color: var(--text-main);
}

.mail-row.active::before {
    display: none;
}

.mail-row.unread {
    background: var(--bg-elevated);
}

.mail-row.unread .mail-row-sender {
    color: var(--primary-light);
    font-weight: 700;
}

.mail-row.unread .mail-row-subject {
    color: var(--text-main);
    font-weight: 600;
}

.mail-row.unread::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.star-btn {
    position: absolute;
    right: 36px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 14px;
    padding: 4px;
    transition: var(--transition);
    z-index: 2;
}

.star-btn:hover {
    color: var(--primary);
    transform: translateY(-50%) scale(1.2);
}

.star-btn.starred {
    color: var(--primary);
}

.mail-row.unread .star-btn {
    right: 36px;
}

.mail-row-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.mail-row-sender {
    font-size: 13.5px;
    color: var(--text-main);
}

.mail-row-date {
    font-size: 11.5px;
    color: var(--text-dim);
}

.mail-row-subject {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.mail-row-snippet {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* AI Suggestions Bar */
.think-dots span {
    display: inline-block;
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    animation: db 1.2s ease-in-out infinite;
}
.think-dots span:nth-child(2) { animation-delay: 0.2s; }
.think-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes db {
    0%,80%,100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
}

.ai-suggestions {
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-reading);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

#ai-suggestions-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.ai-suggestions-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}
.ai-suggestions-label img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}
.ai-suggestion-chip {
    padding: 5px 12px;
    border-radius: 100px;
    background: rgba(255,140,0,0.06);
    border: 1px solid rgba(255,140,0,0.12);
    font-size: 11.5px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}
.ai-suggestion-chip:hover {
    background: rgba(255,140,0,0.12);
    border-color: var(--primary);
    color: var(--primary-light);
}

/* Reading Pane */
.mail-reading-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-reading);
}

.reading-header {
    padding: 28px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-reading);
}

.reading-subject {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 18px;
    letter-spacing: -0.3px;
}

.reading-meta {
    display: flex;
    align-items: center;
    gap: 14px;
}

.reading-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px 40px;
    background: #999999;
    color: #1a1a1a;
    margin: 16px 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    max-width: 800px;
    width: calc(100% - 48px);
    font-size: 15px;
    line-height: 1.8;
}

/* Action Toolbar */
.action-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-reading);
}

.action-toolbar .btn-icon {
    width: 34px;
    height: 34px;
    font-size: 13px;
}

.action-toolbar .btn-icon.danger:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

.action-toolbar .btn-icon.spam:hover {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #000;
}

.action-toolbar .btn-icon.archive:hover {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
}

.action-toolbar .btn-icon.starred,
.action-toolbar .btn-icon.starred:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #000;
}

.action-toolbar .divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 6px;
}

/* Attachment styles */
.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.attachment-item:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.attachment-item i {
    font-size: 14px;
    color: var(--primary);
}

/* Compose attachments */
.attachment-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--border);
}

.attachment-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--primary-subtle);
    border: 1px solid rgba(255, 140, 0, 0.2);
    border-radius: 100px;
    font-size: 11.5px;
    color: var(--primary-light);
}

.attachment-chip button {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 0;
    font-size: 11px;
    line-height: 1;
}

.attachment-chip button:hover {
    color: #f87171;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-card);
    width: 680px;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-bright);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--glass-border);
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.compose-textarea {
    flex: 1;
    min-height: 300px;
    background: transparent;
    border: none;
    resize: none;
    outline: none;
    color: var(--text-main);
    padding: 20px 24px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
}

.compose-textarea::placeholder {
    color: var(--text-dim);
}

/* Utility Buttons */
.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 14px;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    transform: scale(1.05);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-dim);
    gap: 12px;
}

.empty-state i {
    font-size: 36px;
    opacity: 0.15;
    color: var(--primary);
}

.empty-state p {
    font-size: 14px;
}

/* Quota */
.quota-bar-container {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.sidebar.collapsed .quota-bar-container {
    padding: 16px 20px;
}

.quota-bar {
    height: 3px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.quota-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.quota-text {
    font-size: 10.5px;
    color: var(--text-dim);
    text-align: center;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 25%,
        var(--border-bright) 50%,
        var(--bg-elevated) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-row {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.skeleton-row::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
}

.skeleton-line.short { width: 30%; }
.skeleton-line.medium { width: 60%; }
.skeleton-line.long { width: 85%; }

.skeleton-reading-header {
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.skeleton-reading-header .skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 25%,
        var(--border-bright) 50%,
        var(--bg-elevated) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-reading);
}

/* Responsive mail layout */
@media (max-width: 900px) {
    .mail-list-pane {
        width: 100%;
        min-width: 0;
    }

    .mail-reading-pane {
        display: none;
    }

    .mail-reading-pane.visible {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 100;
        background: var(--bg-reading);
    }

    .mail-reading-pane.visible .reading-body {
        margin: 12px;
        padding: 20px;
    }

    .mail-reading-pane.visible .reading-header {
        padding: 20px;
    }

    .mail-reading-pane.visible .action-toolbar {
        padding: 10px 16px;
    }

    .mail-reading-pane .back-btn {
        display: inline-flex;
    }

    .reading-subject {
        font-size: 18px;
    }
}

.mail-reading-pane .back-btn {
    display: none;
}

@media (max-width: 768px) {
    .topbar { padding: 0 16px; }
    .search-box { max-width: 100%; }
    .topbar-right { gap: 8px; }
    .sidebar:not(.collapsed) { width: 260px; }
}

@media (max-width: 600px) {
    .sidebar.collapsed { width: 0; border-right: none; }
    .sidebar.collapsed .logo-area,
    .sidebar.collapsed .compose-area,
    .sidebar.collapsed .nav-area,
    .sidebar.collapsed .quota-bar-container { display: none; }
    .sidebar.collapsed .sidebar-toggle { right: -30px; }
}

/* Hover feedback on mail rows */
.mail-row {
    transition: var(--transition), background 0.15s ease;
}

.mail-row:active {
    transform: scale(0.998);
}

/* Toast enter/exit animation */
@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(12px) scale(0.96); }
}

/* Empty state animation */
.empty-state i {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.empty-state:hover i {
    transform: scale(1.1);
    opacity: 0.25;
}

/* Quota bar glow on update */
.quota-bar-fill {
    position: relative;
}

.quota-bar-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, var(--primary));
    opacity: 0.3;
    border-radius: 3px;
}

/* File input label styling */
input[type="file"] {
    display: none;
}

/* Compose field focus states */
#m-to:focus,
#m-subject:focus {
    box-shadow: 0 1px 0 var(--primary);
}

/* Smooth scroll for reading pane */
.reading-body {
    scroll-behavior: smooth;
}

/* Nav item subtle active indicator */
.nav-item.active i {
    color: var(--primary);
}

/* --- AI View --- */
.ai-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.ai-view.has-result {
    justify-content: flex-start;
    padding: 32px 40px;
    align-items: stretch;
}

.ai-logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
    position: relative;
}

.ai-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    transition: all 1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.ai-logo.animating {
    animation: aiSpinGrow 2.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes aiSpinGrow {
    0% {
        transform: scale(0.2) rotate(0deg);
        opacity: 0;
    }
    30% {
        transform: scale(1.3) rotate(540deg);
        opacity: 1;
    }
    60% {
        transform: scale(0.95) rotate(900deg);
        opacity: 1;
    }
    80% {
        transform: scale(1.05) rotate(1080deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(1260deg);
        opacity: 1;
    }
}

.ai-logo.processing {
    animation: aiPulse 1.2s ease-in-out infinite;
}

@keyframes aiPulse {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    25% {
        transform: scale(1.08) rotate(90deg);
        opacity: 0.9;
    }
    50% {
        transform: scale(1) rotate(180deg);
        opacity: 1;
    }
    75% {
        transform: scale(1.08) rotate(270deg);
        opacity: 0.9;
    }
}

.ai-glow {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 140, 0, 0.15) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.ai-glow.visible {
    opacity: 1;
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.15; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 0.3; }
}

.ai-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.3px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.6s ease 0.3s;
}

.ai-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.ai-subtitle {
    font-size: 13px;
    color: var(--text-dim);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.6s ease 0.5s;
}

.ai-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

#ai-reply-label {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s ease;
}
#ai-reply-label.visible {
    opacity: 1;
    transform: translateY(0);
}

/* AI Quoted Mail Preview */
.ai-quoted-mail {
    width: 100%;
    max-width: 680px;
    margin: -4px auto 8px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s ease;
}
.ai-quoted-mail.visible {
    opacity: 1;
    transform: translateY(0);
}
.ai-quoted-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 4px;
}
.ai-quoted-header i {
    font-size: 10px;
}
.ai-quoted-body {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* AI Input Bar */
.ai-input-container {
    width: 100%;
    max-width: 680px;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease 0.7s;
    margin-top: 10px;
}

.ai-input-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.ai-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-lg);
    padding: 6px;
    transition: var(--transition);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.ai-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle), 0 8px 32px rgba(255, 140, 0, 0.1);
}

.ai-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
    padding: 10px 14px;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
}

.ai-input::placeholder {
    color: var(--text-dim);
}

.ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: var(--transition);
    flex-shrink: 0;
}

.ai-send-btn:hover {
    background: var(--primary-light);
    transform: scale(1.05);
    box-shadow: 0 4px 16px var(--primary-glow);
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* AI Result */
.ai-result {
    width: 100%;
    max-width: 680px;
    margin-top: 24px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.ai-result.visible {
    opacity: 1;
    transform: translateY(0);
}

.ai-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.ai-result-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-result-actions {
    display: flex;
    gap: 6px;
}

.ai-result-body {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-main);
    white-space: pre-wrap;
    min-height: 120px;
    max-height: 400px;
    overflow-y: auto;
}

.ai-result-body[contenteditable="true"]:focus {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    border-color: var(--primary);
}

.ai-regenerate-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.ai-regenerate-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

/* AI view hidden state */
.ai-view-hidden {
    display: none !important;
}

/* Draft entrance animations */
@keyframes draftFadeSlide {
    0% { opacity: 0; transform: translateY(16px); }
    100% { opacity: 1; transform: translateY(0); }
}

.ai-draft-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    animation: draftFadeSlide 0.5s ease-out both;
}

.ai-draft-recipient {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
    animation: draftFadeSlide 0.5s ease-out 0.1s both;
}

.ai-draft-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.ai-draft-brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.2px;
}

/* Draft view after result */
.ai-draft-view {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
}

.ai-draft-recipient {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.ai-draft-recipient:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.ai-draft-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    min-width: 40px;
}

.ai-draft-to {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
}

.ai-draft-to::placeholder {
    color: var(--text-dim);
}

.ai-draft-body {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-main);
    white-space: pre-wrap;
    min-height: 180px;
    max-height: 480px;
    overflow-y: auto;
    animation: draftFadeSlide 0.5s ease-out 0.2s both;
}

.ai-draft-body[contenteditable="true"]:focus {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    border-color: var(--primary);
}

.ai-draft-input-area {
    width: 100%;
    animation: draftFadeSlide 0.5s ease-out 0.3s both;
}

.ai-draft-input-area .ai-input-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: none;
}

.ai-draft-input-area .ai-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.ai-draft-input-area .ai-input {
    padding: 8px 12px;
    font-size: 13px;
}

.ai-draft-input-area .ai-send-btn {
    width: 34px;
    height: 34px;
    font-size: 13px;
}

.ai-draft-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
    animation: draftFadeSlide 0.5s ease-out 0.4s both;
}

/* When AI is active, hide the mail list sidebar */
.mail-list-pane.ai-active {
    display: none;
}

/* Settings button icon hover fix */
.topbar-right .btn-icon:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

/* Profile Dropdown */
.profile-wrapper {
    position: relative;
    z-index: 999;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: var(--transition);
    z-index: 100;
    overflow: hidden;
}

.profile-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-dropdown {
    animation: dropdownSlide 0.2s ease-out;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.dropdown-header {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.dropdown-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #ff5500, var(--primary-light));
    background-size: 200% 200%;
    animation: avatarShimmer 3s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #000;
    flex-shrink: 0;
    position: relative;
}

.dropdown-header {
    position: relative;
}

.dropdown-header::after {
    content: '';
    position: absolute;
    bottom: 14px;
    left: 40px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border: 2px solid var(--bg-card);
    border-radius: 50%;
    z-index: 1;
}

.dropdown-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-email {
    font-size: 11.5px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item i {
    width: 18px;
    font-size: 14px;
    text-align: center;
    color: var(--text-dim);
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--primary-light);
}

.dropdown-item:hover i {
    color: var(--primary);
}

.dropdown-item.danger:hover {
    background: rgba(248, 113, 113, 0.08);
    color: #f87171;
}

.dropdown-item.danger:hover i {
    color: #f87171;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Settings Modal */
.settings-section {
    padding: 6px 0;
}

.settings-section-title {
    padding: 16px 24px 8px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    transition: var(--transition);
}

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

.settings-label {
    font-size: 13.5px;
    color: var(--text-main);
    font-weight: 500;
}

.settings-desc {
    font-size: 11.5px;
    color: var(--text-dim);
    margin-top: 2px;
}

.settings-input {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    color: var(--text-main);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    width: 240px;
    transition: var(--transition);
}

.settings-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.settings-select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    color: var(--text-main);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.settings-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.settings-textarea {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-main);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    width: 240px;
    min-height: 72px;
    resize: vertical;
    transition: var(--transition);
}

.settings-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.settings-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-bright);
    border-radius: 22px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: #000;
}
