:root {
    /* Clean Light Theme - Notion/Linear inspired */
    --bg-app: #ffffff;
    --bg-sidebar: #fafafa;
    --bg-panel: #ffffff;
    --bg-hover: #f5f5f5;
    --bg-selected: #f0f0f0;

    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;

    --border-color: #e5e5e5;
    --border-subtle: #f0f0f0;

    --accent-color: #2563eb;
    --accent-light: #eff6ff;
    --danger-color: #dc2626;

    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

html,
body {
    font-family: var(--font-stack);
    background: var(--bg-app);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 220px 300px 1fr;
    height: 100vh;
}

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

.sidebar-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h2 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Mailbox Item */
.mailbox-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    border-radius: 6px;
    margin-bottom: 2px;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
    /* border: 1px solid transparent; Removed to ensure no layout shift */
}

.mailbox-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.mailbox-item.active {
    background: var(--accent-light);
    color: var(--accent-color);
    /* font-weight: 500; Removed to prevent layout shift */
}

.sidebar-footer {
    padding: 12px 16px;
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: center;
    border-top: 1px solid var(--border-subtle);
}

/* Message List */
.message-list {
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.list-header {
    height: 52px;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.list-header h3 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

.actions {
    display: flex;
    gap: 4px;
}

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

.message-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    /* border-left: 3px solid transparent; Removed - utilizing box-shadow for indicator */
    transition: background 0.1s;
    background-color: var(--bg-panel);
    /* Explicit background */
}

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

.message-item.active {
    background-color: var(--accent-light);
    /* Use box-shadow inset for indicator - Zero layout shift guaranteed */
    box-shadow: inset 3px 0 0 var(--accent-color);
}

.message-item.active .msg-sender {
    color: var(--accent-color);
}

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

.msg-sender {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.msg-time {
    font-size: 11px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.msg-subject {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* Reading Pane */
.reading-pane {
    background: var(--bg-app);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.detail-header {
    padding: 24px 28px;
    border-bottom: 1px solid var(--border-subtle);
}

.detail-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.detail-title-row h1 {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
}

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

.sender-info .label,
.recipient-info .label {
    color: var(--text-tertiary);
}

.sender-info .value {
    color: var(--text-primary);
}

.detail-content {
    padding: 24px 28px;
    line-height: 1.7;
    color: var(--text-primary);
    flex: 1;
}

.detail-content img {
    max-width: 100%;
}

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

.empty-state svg {
    opacity: 0.5;
    margin-bottom: 12px;
}

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

/* Components */
.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

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

.icon-btn.danger:hover {
    color: var(--danger-color);
    background: #fef2f2;
}

.btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.btn.primary {
    background: var(--accent-color);
    color: white;
}

.btn.primary:hover {
    background: #1d4ed8;
}

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

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

.btn.secondary.danger-text {
    color: var(--danger-color);
}

.btn.secondary.danger-text:hover {
    background: #fef2f2;
    border-color: #fecaca;
}

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

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: white;
    padding: 24px;
    border-radius: 8px;
    width: 320px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.modal h3 {
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 600;
}

.modal input {
    width: 100%;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-primary);
}

.modal input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.modal input::placeholder {
    color: var(--text-tertiary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 200;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, 8px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Search Box */
.search-box {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary);
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-color);
}

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

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-sidebar);
}

.message-list .pagination {
    background: var(--bg-panel);
}

.page-btn {
    padding: 6px 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

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

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

.page-info {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-overlay.hidden {
    display: none;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    width: 320px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.login-box h2 {
    margin-bottom: 8px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.login-hint {
    margin-bottom: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.login-box input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}

.login-box input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.login-box .btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
}

.login-error {
    margin-top: 12px;
    font-size: 13px;
    color: var(--danger-color);
}

.login-error.hidden {
    display: none;
}