/* ===== 全局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --red-deep: #b71c1c;
  --red-main: #e53935;
  --red-light: #ffcdd2;
  --red-bg: #fff5f5;
  --red-soft: #ffebee;
  --text-dark: #3e2723;
  --text-mid: #795548;
  --text-light: #bcaaa4;
  --white: #ffffff;
  --shadow: 0 8px 32px rgba(183, 28, 28, 0.12);
  --shadow-hover: 0 12px 40px rgba(183, 28, 28, 0.2);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--red-bg);
  color: var(--text-dark);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

.page {
  min-height: 100vh;
}

/* ===== 登录页（简洁普通样式） ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #f5f5f5;
}

.login-card {
  background: var(--white);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 32px 28px;
  width: 100%;
  max-width: 340px;
}

.login-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 6px;
  text-align: center;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 24px;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.login-form input:focus {
  border-color: #888;
}

/* ===== 按钮 ===== */
.btn-primary {
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--red-main), var(--red-deep));
  color: var(--white);
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(229, 57, 53, 0.35);
}

.btn-primary:active { transform: translateY(0); }

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* 登录页按钮用普通样式 */
.login-page .btn-primary {
  padding: 10px 16px;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: none;
}

.login-page .btn-primary:hover {
  background: #000;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  padding: 8px 16px;
  background: transparent;
  color: var(--red-main);
  border: 1.5px solid var(--red-light);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover {
  background: var(--red-soft);
  border-color: var(--red-main);
}

.error-msg {
  color: var(--red-main);
  font-size: 13px;
  margin-top: 16px;
  min-height: 18px;
}

/* ===== 主界面 ===== */
.main-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--red-deep);
}

.welcome-heart {
  color: var(--red-main);
  font-size: 20px;
  animation: heartbeat 1.5s ease-in-out infinite;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: var(--white);
  padding: 6px;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(183, 28, 28, 0.06);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-mid);
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--red-main), var(--red-deep));
  color: var(--white);
  box-shadow: 0 4px 12px rgba(229, 57, 53, 0.3);
}

.badge {
  background: var(--white);
  color: var(--red-main);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 信件列表 ===== */
.letter-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.letter-item {
  background: var(--white);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 2px 12px rgba(183, 28, 28, 0.06);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border-left: 4px solid var(--red-light);
  position: relative;
}

.letter-item:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow);
}

.letter-item.unread {
  border-left-color: var(--red-main);
  background: linear-gradient(135deg, var(--white), var(--red-soft));
}

.letter-item.unread::after {
  content: '';
  position: absolute;
  top: 18px;
  right: 18px;
  width: 10px;
  height: 10px;
  background: var(--red-main);
  border-radius: 50%;
}

.letter-from {
  font-weight: 600;
  color: var(--red-deep);
  font-size: 15px;
  margin-bottom: 6px;
}

.letter-preview {
  color: var(--text-mid);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.letter-time {
  color: var(--text-light);
  font-size: 12px;
}

.empty-tip {
  text-align: center;
  color: var(--text-light);
  padding: 60px 20px;
  font-size: 14px;
}

/* ===== 写信 ===== */
.write-card {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(183, 28, 28, 0.06);
}

.write-to {
  font-size: 15px;
  color: var(--text-mid);
  margin-bottom: 16px;
}

.recipient-name {
  color: var(--red-deep);
  font-weight: 600;
}

.letter-textarea {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--red-light);
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.7;
  resize: vertical;
  min-height: 160px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  font-family: inherit;
  background: var(--red-soft);
}

.letter-textarea:focus {
  border-color: var(--red-main);
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.15);
  background: var(--white);
}

.write-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.char-count {
  font-size: 12px;
  color: var(--text-light);
}

.send-msg {
  margin-top: 12px;
  font-size: 13px;
  min-height: 18px;
}

.send-msg.success { color: #43a047; }
.send-msg.error { color: var(--red-main); }

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(62, 39, 35, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--white);
  border-radius: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--red-soft);
  background: var(--red-soft);
}

.modal-from {
  font-weight: 600;
  color: var(--red-deep);
  font-size: 16px;
}

.modal-time {
  color: var(--text-light);
  font-size: 12px;
  flex: 1;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-mid);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-close:hover { color: var(--red-main); }

.modal-body {
  padding: 24px 20px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-dark);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: calc(80vh - 70px);
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .login-card { padding: 36px 24px; }
  .login-title { font-size: 24px; }
  .heart-icon { font-size: 48px; }
  .main-page { padding: 0 12px 32px; }
}
