* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #e8e8e8;
  --danger: #ff4d4f;
  --success: #52c41a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ==================== 登录页 ==================== */

.login-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-logo {
  width: 80px;
  height: 80px;
  background: white;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin-bottom: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.login-title {
  color: white;
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}

.login-desc {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  margin-bottom: 40px;
  text-align: center;
}

.login-btn {
  background: white;
  color: var(--primary);
  border: none;
  padding: 14px 48px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.login-btn:active {
  transform: translateY(0);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-note {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  margin-top: 16px;
}

/* ==================== 主界面 ==================== */

.main-section {
  display: none;
}

/* 顶部栏 */
.header {
  background: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo {
  font-size: 24px;
}

.header-title {
  font-size: 16px;
  font-weight: 600;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-name {
  font-size: 13px;
  color: var(--text-secondary);
}

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.logout-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* Tab 栏 */
.tab-bar {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 8px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-btn:hover {
  color: var(--primary);
}

/* Tab 内容 */
.tab-content {
  display: none;
  padding: 12px;
}

.tab-content.active {
  display: block;
}

/* 工具栏 */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-box {
  flex: 1;
  display: flex;
  gap: 4px;
}

.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
}

/* 按钮 */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-outline {
  background: white;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* 面包屑导航 */
.breadcrumb {
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.breadcrumb-item {
  cursor: pointer;
  color: var(--primary);
}

.breadcrumb-item.active {
  color: var(--text);
  cursor: default;
}

.breadcrumb-sep {
  margin: 0 4px;
  color: var(--text-muted);
}

/* ==================== 列表项 ==================== */

.list-item {
  background: var(--card-bg);
  padding: 14px 16px;
  margin-bottom: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: box-shadow 0.2s;
  border: 1px solid var(--border);
}

.list-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.list-item.unread {
  border-left: 3px solid var(--primary);
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.item-from {
  font-weight: 600;
  font-size: 14px;
}

.item-date {
  font-size: 12px;
  color: var(--text-muted);
}

.item-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  line-height: 1.4;
}

.item-preview {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 文件项 */
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  min-width: 0;
}

/* ==================== 模态框 ==================== */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* 预览工具栏与框架 */
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.preview-title {
  font-weight: 600;
  font-size: 15px;
}
.preview-actions { display:flex; gap:8px; align-items:center; }
.preview-frame { width:100%; }

/* iOS 风格分享面板 */
.share-sheet {
  display:flex;
  justify-content:center;
  padding:12px 0;
}
.share-card {
  width:100%;
  max-width:520px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), #fff);
  border-radius:16px;
  padding:16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.04);
}
.share-title { font-size:16px; font-weight:600; margin-bottom:8px; }
.share-link { word-break:break-all; color:var(--text-secondary); background:#f7f7fb; padding:10px;border-radius:8px;margin-bottom:12px; }
.share-actions { display:flex; gap:8px; justify-content:flex-end; }
.share-actions .btn { padding:8px 12px; border-radius:8px; }

/* 更大的模态内容用于文件预览 */
.modal-content.fullscreen { width:100%; max-width:900px; max-height:95vh; border-radius:10px; }

/* 邮件详情 */
.email-detail p {
  margin-bottom: 8px;
  font-size: 13px;
}

.email-body {
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.email-body img {
  max-width: 100%;
  height: auto;
}

/* 表单 */
.compose-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--primary);
}

.form-textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  resize: vertical;
  font-family: inherit;
}

/* ==================== 状态提示 ==================== */

.loading,
.empty,
.error {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.error {
  color: var(--danger);
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast-error {
  background: #fff2f0;
  color: var(--danger);
  border: 1px solid #ffccc7;
}

.toast-success {
  background: #f6ffed;
  color: var(--success);
  border: 1px solid #b7eb8f;
}

.toast-info {
  background: #e6f7ff;
  color: var(--primary);
  border: 1px solid #91d5ff;
}

/* ==================== 响应式 ==================== */

@media (max-width: 480px) {
  .header-title {
    font-size: 14px;
  }

  .tab-btn {
    font-size: 13px;
    padding: 10px 4px;
  }

  .modal-content {
    max-height: 90vh;
  }
}
