/* 董事长信箱 用户端样式 */
:root {
  --bg: #EAF3FB;
  --card: #FFFFFF;
  --primary: #1F6FB2;
  --primary-hover: #185E96;
  --accent: #2BA89E;
  --text: #1F2937;
  --text-sub: #6B7280;
  --border: #D6E4F0;
  --error: #D14343;
  --radius: 8px;
}

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

html, body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }

.container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== 顶部品牌 ===== */
.brand-header {
  text-align: center;
  padding: 36px 20px 20px;
}
.brand-header img { width: 56px; height: 56px; object-fit: contain; }
.brand-header .brand-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
  margin-top: 10px;
}
.brand-header .brand-sub {
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 4px;
}

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(31,111,178,0.08);
  padding: 20px;
  margin: 0 16px 16px;
}

/* ===== 按钮 ===== */
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  display: block;
  font-size: 14px;
  color: var(--text-sub);
  margin-bottom: 6px;
}
.form-input, .form-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-textarea { min-height: 140px; resize: vertical; }

/* 信纸横线 */
.letter-paper {
  background-image: repeating-linear-gradient(
    transparent,
    transparent 31px,
    var(--border) 31px,
    var(--border) 32px
  );
  line-height: 32px;
  padding-top: 4px;
}

/* ===== 图形验证码 ===== */
.captcha-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.captcha-row .form-input { flex: 1; }
.captcha-img {
  height: 44px;
  width: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.captcha-img svg { width: 100%; height: 100%; }

.sms-row { display: flex; gap: 10px; }
.sms-row .form-input { flex: 1; }
.sms-btn {
  white-space: nowrap;
  padding: 12px 14px;
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}
.sms-btn:disabled { color: var(--text-sub); border-color: var(--border); cursor: not-allowed; }

.divider {
  text-align: center;
  color: var(--text-sub);
  font-size: 13px;
  margin: 8px 0;
  position: relative;
}
.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

/* ===== 主页头部 ===== */
.page-header {
  background: var(--card);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.page-header .title { font-size: 17px; font-weight: 700; color: var(--text); }
.page-header .user-info { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-sub); }
.page-header .logout-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-sub);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

/* ===== Tab 栏 ===== */
.tab-bar {
  display: flex;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.tab-item {
  flex: 1;
  text-align: center;
  padding: 14px;
  font-size: 15px;
  color: var(--text-sub);
  cursor: pointer;
  position: relative;
  font-family: inherit;
  background: none;
  border: none;
}
.tab-item.active { color: var(--primary); font-weight: 600; }
.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 25%;
  width: 50%;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

.tab-content { flex: 1; padding: 16px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===== 写信 ===== */
.write-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(31,111,178,0.08);
  margin-bottom: 16px;
  overflow: hidden;
}
.write-card .brand-mark {
  text-align: center;
  padding: 12px;
  font-style: italic;
  font-size: 18px;
  color: var(--accent);
  font-family: Georgia, serif;
  letter-spacing: 2px;
}
.write-card .card-body { padding: 16px; }

.field-label {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
  font-weight: 500;
}
.title-row { display: flex; align-items: baseline; gap: 6px; }
.title-row .field-label { white-space: nowrap; }
.title-count { font-size: 12px; color: var(--text-sub); margin-left: auto; }

.category-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 13px;
  color: var(--text-sub);
  cursor: pointer;
  user-select: none;
  background: #fff;
}
.chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.contact-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.contact-section { margin-top: 10px; display: none; }
.contact-section.show { display: block; }

/* 图片上传 */
.upload-area { margin-top: 8px; }
.upload-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.thumb {
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-btn {
  width: 80px;
  height: 80px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--text-sub);
  cursor: pointer;
  background: #fff;
}
.upload-btn input { display: none; }
.upload-tip { font-size: 12px; color: var(--text-sub); margin-top: 6px; }

/* ===== 过往信件 ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-sub);
  font-size: 15px;
}
.letter-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(31,111,178,0.06);
}
.letter-item .li-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.letter-item .li-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.letter-item .li-cat {
  font-size: 12px;
  color: var(--accent);
  background: rgba(43,168,158,0.1);
  padding: 2px 8px;
  border-radius: 10px;
}
.letter-item .li-time { font-size: 12px; color: var(--text-sub); }
.letter-item .li-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: auto;
}
.status-new { background: rgba(209,67,67,0.1); color: var(--error); }
.status-read { background: rgba(107,114,128,0.1); color: var(--text-sub); }

.letter-item .li-reply-row { margin-top: 6px; }
.letter-item .li-reply {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 10px;
}
.li-reply-new {
  background: rgba(31,111,178,0.12);
  color: var(--primary);
  font-weight: 600;
}
.li-reply-read {
  background: rgba(43,168,158,0.12);
  color: var(--accent);
}

/* ===== 弹窗（用户端） ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  position: relative;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-sub);
  line-height: 1;
}
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* 详情/回复区块 */
.detail-section { margin-bottom: 14px; }
.detail-label { font-size: 13px; color: var(--text-sub); margin-bottom: 4px; }
.detail-value { font-size: 15px; color: var(--text); }
/* 原信件正文（信纸质感）与图片 */
.detail-body {
  font-size: 15px;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.8;
  background: #FCFAF3;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 8px;
}
.detail-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.detail-images img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }

/* 回复条目 */
.reply-item {
  background: #F7FBFE;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.reply-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.reply-title { font-size: 15px; font-weight: 600; color: var(--primary); flex: 1; }
.reply-time { font-size: 12px; color: var(--text-sub); white-space: nowrap; }
.reply-body {
  font-size: 15px;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.6;
}
.reply-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.reply-images img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }

/* ===== 提示 ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31,41,55,0.9);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 9999;
  max-width: 90%;
  text-align: center;
}
.toast.error { background: var(--error); }

/* ===== 非微信浏览器遮罩 ===== */
.wechat-only-mask {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.wechat-only-mask .mask-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 2px 10px rgba(31,111,178,0.12);
}
.wechat-only-mask .mask-card img { width: 64px; height: 64px; object-fit: contain; }
.wechat-only-mask .mask-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 12px;
  letter-spacing: 1px;
}
.wechat-only-mask .mask-tip {
  font-size: 16px;
  color: var(--text);
  margin-top: 18px;
  font-weight: 500;
}
.wechat-only-mask .mask-sub {
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 8px;
}
