:root {
    --bg-main: #1a1a2e;
    --bg-card: #22223b;
    --bg-input: #2a2a3e;
    --bg-hover: #2e2e45;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0b0;
    --accent: #4a6fa5;
    --accent-light: #5b8cc9;
    --border: #3a3a50;
    --danger: #e74c3c;
    --success: #27ae60;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
.header h1 { font-size: 1.2rem; font-weight: 600; }
.header-actions { display: flex; gap: 0.75rem; align-items: center; }
.header-actions select {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}
.btn {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    background: var(--accent);
    color: #fff;
}
.btn:hover { background: var(--accent-light); }
.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.3rem;
}
.btn-icon:hover { color: var(--text-primary); }

/* Layout */
.main-layout {
    display: flex;
    height: calc(100vh - 52px);
}

/* Mail list */
.mail-list {
    width: 400px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
}
.mail-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}
.mail-item:hover { background: var(--bg-hover); }
.mail-item.active { background: var(--accent); color: #fff; }
.mail-item.active .mail-meta { color: rgba(255,255,255,0.7); }
.mail-item.unread .mail-sender { font-weight: 700; }
.mail-sender {
    font-size: 0.9rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mail-subject {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mail-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    justify-content: space-between;
}
.mail-account {
    font-size: 0.7rem;
    color: var(--accent-light);
    margin-top: 2px;
}

/* Mail detail */
.mail-detail {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}
.mail-detail.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}
.detail-header { margin-bottom: 1.5rem; }
.detail-subject { font-size: 1.3rem; font-weight: 600; margin-bottom: 0.5rem; }
.detail-from { font-size: 0.9rem; color: var(--text-secondary); }
.detail-to { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.25rem; }
.detail-date { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.25rem; }
.detail-body {
    margin-top: 1rem;
    line-height: 1.6;
}
.detail-body iframe {
    width: 100%;
    border: none;
    border-radius: 8px;
    background: #fff;
    min-height: 400px;
}
.detail-attachments {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.attachment-chip {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    background: var(--bg-input);
    border-radius: 6px;
    font-size: 0.8rem;
    margin-right: 0.5rem;
    margin-bottom: 0.25rem;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
}
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
    .mail-list { width: 100%; }
    .mail-detail { display: none; }
    .mail-detail.visible { display: block; }
    .main-layout.detail-open .mail-list { display: none; }
    .main-layout.detail-open .mail-detail { display: block; }
}
