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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #2d3748;
  padding: 20px;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

.container.narrow {
  max-width: 420px;
}

header {
  text-align: center;
  color: #fff;
  margin-bottom: 24px;
}

header h1 {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 14px;
  opacity: 0.85;
}

.mailbox-card,
.mail-list-card,
.detail-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

label {
  display: block;
  font-size: 13px;
  color: #718096;
  margin-bottom: 8px;
  font-weight: 500;
}

.addr-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

input[type="text"],
input[type="password"] {
  flex: 1;
  padding: 12px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

input:focus {
  border-color: #667eea;
}

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

.custom-wrap {
  position: relative;
}

.custom-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-ghost {
  background: #edf2f7;
  color: #4a5568;
}

.btn-ghost:hover {
  background: #e2e8f0;
}

.btn-danger {
  background: #fed7d7;
  color: #c53030;
}

.btn-danger:hover {
  background: #feb2b2;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.list-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: #edf2f7;
  color: #718096;
}

.status.connected {
  background: #c6f6d5;
  color: #22543d;
}

.status.connecting {
  background: #feebc8;
  color: #7b341e;
}

.empty-hint {
  text-align: center;
  padding: 40px 20px;
  color: #a0aec0;
  font-size: 14px;
  line-height: 1.8;
}

.mail-list {
  list-style: none;
}

.mail-item {
  padding: 14px 12px;
  border-bottom: 1px solid #edf2f7;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 6px;
}

.mail-item:hover {
  background: #f7fafc;
}

.mail-item.unread {
  background: #ebf4ff;
}

.mail-item.unread:hover {
  background: #dbeafe;
}

.mail-item .from {
  font-size: 13px;
  color: #4a5568;
  font-weight: 500;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-item .subject {
  font-size: 14px;
  color: #2d3748;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-item .time {
  font-size: 12px;
  color: #a0aec0;
  margin-top: 4px;
}

.mail-item.unread .subject {
  font-weight: 600;
}

.detail-card {
  display: block;
}

.detail-card.hidden {
  display: none;
}

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

#detailSubject {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  word-break: break-word;
}

.detail-meta {
  background: #f7fafc;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #4a5568;
  margin-bottom: 16px;
  line-height: 1.8;
}

.code-hint {
  margin-top: 8px;
  padding: 10px 12px;
  background: #fef5e7;
  border-left: 3px solid #ed8936;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.code-hint.hidden {
  display: none;
}

#codeValue {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 18px;
  font-weight: 700;
  color: #c05621;
  letter-spacing: 2px;
}

.detail-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.tab {
  padding: 8px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #718096;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
  font-weight: 500;
}

.html-frame,
.text-frame {
  width: 100%;
  min-height: 400px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.text-frame {
  padding: 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  color: #2d3748;
}

.hidden {
  display: none !important;
}

.error-text {
  color: #c53030;
  font-size: 13px;
  margin-top: 8px;
  min-height: 16px;
}

@media (max-width: 600px) {
  .addr-row,
  .actions,
  .custom-row {
    flex-direction: column;
  }
  .btn {
    width: 100%;
  }
}
