/* ====== 重置与基础 ====== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f0f13;
  --surface: #1a1a22;
  --surface2: #22222d;
  --border: #2a2a38;
  --text: #e0e0e8;
  --text2: #9090a0;
  --accent: #6c5ce7;
  --accent2: #a29bfe;
  --danger: #e74c3c;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ====== 布局 ====== */
#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

/* ====== 头部 ====== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent2);
}

.domain-badge {
  font-size: 0.85rem;
  color: var(--text2);
  background: var(--surface2);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ====== 生成区 ====== */
.generate-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.gen-row {
  display: flex;
  gap: 12px;
}

.gen-row input {
  flex: 1;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.gen-row input:focus {
  border-color: var(--accent);
}

.btn-primary {
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover { background: #7d6ff0; }
.btn-primary:active { transform: scale(0.97); }

.btn-icon {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
  color: var(--text2);
}

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

.email-display {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.email-addr {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent2);
  word-break: break-all;
}

.email-hint {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text2);
}

/* ====== 主体双栏 ====== */
main {
  display: flex;
  gap: 20px;
  min-height: 500px;
}

/* ====== 侧边栏 ====== */
#sidebar {
  width: 380px;
  min-width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

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

.sidebar-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.count-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}

.email-list {
  flex: 1;
  overflow-y: auto;
  max-height: 520px;
}

.email-list .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text2);
  gap: 8px;
}

.email-list .empty-state p {
  font-size: 0.95rem;
  font-weight: 500;
}

.email-list .empty-state span {
  font-size: 0.8rem;
}

.email-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.email-item:hover { background: var(--surface2); }
.email-item.active { background: var(--surface2); border-left: 3px solid var(--accent); }

.email-item .item-from {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-item .item-subject {
  font-size: 0.85rem;
  color: var(--text2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-item .item-time {
  font-size: 0.75rem;
  color: #666;
  margin-top: 4px;
}

/* ====== 详情面板 ====== */
.detail-panel {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
}

.detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text2);
  font-size: 0.95rem;
}

.detail-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.detail-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.detail-header .detail-subject {
  font-size: 1.2rem;
  font-weight: 700;
}

.detail-header .detail-meta {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text2);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.detail-header .detail-meta span { display: flex; align-items: center; gap: 4px; }
.detail-header .detail-meta strong { color: var(--text); }

.detail-body {
  flex: 1;
  padding: 0;
  overflow-y: auto;
  word-break: break-word;
  background: #ffffff;
  color: #1a1a1a;
  font-size: 14px;
  line-height: 1.7;
}

.detail-body * { max-width: 100%; box-sizing: border-box; }
.detail-body img { height: auto; }
.detail-body a { color: #2563eb; }
.detail-body table { border-collapse: collapse; }
.detail-body td, .detail-body th { border: 1px solid #ddd; padding: 6px 12px; }

.detail-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  color: #333;
  margin: 0;
}

.detail-actions {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.btn-del {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-del:hover {
  background: var(--danger);
  color: #fff;
}

/* ====== 响应式 ====== */
@media (max-width: 768px) {
  main { flex-direction: column; }
  #sidebar { width: 100%; }
  .gen-row { flex-direction: column; }
}
