:root {
    /* Dark Theme */
    --bg: #050505;
    --surface: rgba(20, 20, 20, 0.9);
    --border: rgba(255, 255, 255, 0.12);
    --text-main: #ffffff;
    --text-dim: #888;
    --glass: blur(25px);
    --accent: #fff;
    --hover-bg: rgba(255, 255, 255, 0.08);
    --danger: #ff453a;
}

[data-theme="light"] {
    --bg: #f5f5f7;
    --surface: rgba(255, 255, 255, 0.9);
    --border: rgba(0, 0, 0, 0.1);
    --text-main: #1d1d1f;
    --text-dim: #86868b;
    --glass: blur(25px);
    --accent: #0071e3;
    --hover-bg: rgba(0, 0, 0, 0.05);
    --danger: #ff3b30;
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background-color: var(--bg); color: var(--text-main); font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; height: 100vh; overflow: hidden; font-size: 14px; transition: background 0.3s, color 0.3s; }

/* 基础组件 */
.glass-panel { background: var(--surface); backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass); border: 1px solid var(--border); box-shadow: 0 20px 40px rgba(0,0,0,0.2); }
.view-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; opacity: 0; pointer-events: none; z-index: 1; transition: opacity 0.3s; }
.view-container.active { opacity: 1; pointer-events: all; z-index: 2; }

/* 登录页 */
#view-auth { align-items: center; justify-content: center; }
.auth-card { width: 400px; padding: 40px; border-radius: 24px; }
.auth-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.brand { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.subtitle { color: var(--text-dim); font-size: 13px; margin-bottom: 30px; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 30px; }
.auth-tab { flex: 1; text-align: center; padding: 12px; cursor: pointer; color: var(--text-dim); border-bottom: 2px solid transparent; transition: 0.3s; }
.auth-tab.active { color: var(--text-main); font-weight: 600; border-bottom-color: var(--accent); }
.auth-form { display: none; flex-direction: column; animation: fadeIn 0.3s ease; }
.auth-form.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* 输入框 */
.input-group { position: relative; margin-bottom: 24px; }
input { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--border); padding: 12px 0; color: var(--text-main); font-size: 15px; border-radius: 0; transition: border 0.3s; }
input:focus { border-color: var(--accent); }
input::placeholder { opacity: 0; }
.input-group label { position: absolute; top: 12px; left: 0; color: var(--text-dim); pointer-events: none; transition: 0.3s ease; font-size: 15px; }
input:focus ~ label, input:not(:placeholder-shown) ~ label { top: -10px; font-size: 12px; color: var(--text-main); }

/* 按钮 */
.btn-primary { background: var(--text-main); color: var(--bg); border: none; padding: 14px; border-radius: 12px; font-weight: 600; cursor: pointer; width: 100%; transition: opacity 0.2s; font-size: 14px; }
.btn-primary:active { opacity: 0.8; }
.btn-text { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 8px 12px; border-radius: 6px; transition: 0.2s; }
.btn-text:hover { background: var(--hover-bg); color: var(--text-main); }
.btn-text.danger:hover { color: var(--danger); background: rgba(255, 69, 58, 0.1); }

/* 顶部栏 */
.top-bar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--border); z-index: 10; }
.bar-center { display: flex; gap: 12px; flex: 1; justify-content: center; align-items: center; }
.mailbox-selector-wrapper select { background: var(--hover-bg); border: 1px solid var(--border); color: var(--text-main); padding: 8px 16px; border-radius: 8px; outline: none; cursor: pointer; font-size: 14px; min-width: 200px; }
.mailbox-selector-wrapper select option { background: var(--surface); color: var(--text-main); }
.btn-icon-text { background: transparent; border: 1px solid transparent; color: var(--text-dim); padding: 8px 12px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 13px; transition: 0.2s; }
.btn-icon-text:hover { background: var(--hover-bg); color: var(--text-main); }
.btn-icon-text.danger:hover { color: var(--danger); background: rgba(255, 69, 58, 0.1); }

/* 分栏布局 */
.split-view { display: flex; flex: 1; height: calc(100vh - 64px); }
.list-pane { width: 340px; border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; display: flex; flex-direction: column; }
.message-item { padding: 16px 24px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.2s; }
.message-item:hover { background: var(--hover-bg); }
.message-item.selected { background: var(--selected-bg); border-left: 3px solid var(--text-main); }
.msg-top { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.msg-sender { font-weight: 600; color: var(--text-main); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { color: var(--text-dim); font-size: 12px; }
.msg-subject { color: var(--text-main); font-size: 14px; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-intro { color: var(--text-dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 右侧内容 */
.content-pane { flex: 1; background: var(--bg); overflow-y: auto; position: relative; }
.content-placeholder { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-dim); }
#email-detail-view { padding: 40px; max-width: 900px; margin: 0 auto; }
.email-detail-top { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--border); padding-bottom: 24px; margin-bottom: 30px; }
.email-meta h2 { margin: 0 0 12px 0; font-size: 22px; color: var(--text-main); line-height: 1.3; }
.meta-row { display: flex; margin-bottom: 6px; font-size: 13px; }
.meta-row .label { width: 70px; color: var(--text-dim); }
.meta-row .value { color: var(--text-main); font-family: 'JetBrains Mono', monospace; }
/* 邮件内容容器 */
.email-body-container { background: #fff; padding: 30px; border-radius: 12px; color: #000; min-height: 300px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }

/* ============ 优化后的模态框 ============ */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); z-index: 100; display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: 0.3s; }
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-card { width: 90%; max-width: 500px; padding: 32px; border-radius: 24px; background: var(--surface); color: var(--text-main); max-height: 85vh; overflow-y: auto; }
.modal-card h3 { margin: 0 0 24px 0; font-size: 20px; font-weight: 600; }

/* 设置卡片样式 */
.setting-card { background: var(--hover-bg); border-radius: 12px; padding: 20px; margin-bottom: 20px; border: 1px solid var(--border); }
.setting-card h4 { margin: 0 0 16px 0; font-size: 14px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
.setting-desc { font-size: 12px; color: var(--text-dim); margin-bottom: 15px; line-height: 1.5; }
.danger-zone { border-color: rgba(255, 69, 58, 0.3); background: rgba(255, 69, 58, 0.05); }
.danger-zone h4 { color: var(--danger); }

/* 邮箱别名管理优化 */
.add-alias-group { display: flex; gap: 10px; align-items: center; margin-bottom: 24px; background: var(--hover-bg); padding: 6px; border-radius: 12px; border: 1px solid var(--border); }
.add-alias-group input { border: none; padding: 10px 15px; flex: 1; border-radius: 0; background: transparent; }
.add-alias-group .domain-sep { color: var(--text-dim); }
.add-alias-group select { background: transparent; border: none; color: var(--text-main); outline: none; padding: 0 10px; cursor: pointer; }
.add-alias-group select option { background: #000; }
.btn-add-alias { background: var(--text-main); color: var(--bg); border: none; padding: 8px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; white-space: nowrap; }

.alias-list { margin-top: 10px; border-top: 1px solid var(--border); }
.alias-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.alias-info { display: flex; align-items: center; gap: 10px; }
.alias-address { font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.tag-primary { background: var(--text-main); color: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; }

.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }

/* 滚动条美化 */
.custom-scroll::-webkit-scrollbar { width: 5px; }
.custom-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.toast { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); background: var(--text-main); color: var(--bg); padding: 12px 30px; border-radius: 50px; font-weight: 600; z-index: 200; box-shadow: 0 10px 30px rgba(0,0,0,0.3); pointer-events: none; transition: opacity 0.3s; }