/* ---- 基础 ---- */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- 布局 ---- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.site-header nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.who { color: var(--muted); font-size: 14px; }

main { max-width: 880px; margin: 0 auto; padding: 24px 16px 64px; }

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px;
  border-top: 1px solid var(--line);
}

.site-footer p { margin: 4px 0; }

/* ICP 备案号：字号略小、对比度略低，不喧宾夺主 */
.beian {
  font-size: 12px;
  opacity: .85;
}

.beian a {
  color: var(--muted);
  text-decoration: none;
}

.beian a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ---- 组件 ---- */
.hero { text-align: center; padding: 32px 0 16px; }
.hero h1 { margin: 0 0 8px; font-size: 28px; }
.hero p { color: var(--muted); margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  margin: 16px 0;
}
.card.narrow { max-width: 440px; margin: 32px auto; }
.card.center { text-align: center; }
.card h1, .card h2 { margin-top: 0; font-size: 20px; }

.stack { display: grid; gap: 10px; }
.stack label { font-size: 14px; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
input:focus, textarea:focus {
  outline: 2px solid rgba(37, 99, 235, .35);
  border-color: var(--accent);
}
textarea { resize: vertical; }

button, .button {
  display: inline-block;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-dark); text-decoration: none; }
button.danger { background: var(--danger); padding: 6px 12px; font-size: 14px; }
button.link {
  background: none;
  color: var(--accent);
  padding: 0;
  font: inherit;
  border: 0;
  cursor: pointer;
}
form.inline { display: inline; }

.alert { padding: 10px 14px; border-radius: 8px; margin: 12px 0; font-size: 14px; }
.alert.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert.success { background: #f0fdf4; color: var(--ok); border: 1px solid #bbf7d0; }
.alert.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* 邮箱验证状态小标签 */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  vertical-align: middle;
}
.tag.ok { background: #f0fdf4; color: var(--ok); border: 1px solid #bbf7d0; }
.tag.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.muted { color: var(--muted); font-size: 14px; }

/* ---- 留言列表 ---- */
.messages { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.messages li { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.messages li:last-child { border-bottom: 0; padding-bottom: 0; }
.messages .meta { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.messages time { color: var(--muted); font-size: 13px; }
.messages .body { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; }

/* ---- 后台表格 ---- */
.stats { display: flex; gap: 16px; margin: 16px 0; flex-wrap: wrap; }
.stat {
  flex: 1 1 120px;
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
}
.stat .num { font-size: 24px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table td.body { max-width: 360px; word-break: break-word; }

@media (max-width: 600px) {
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .hero h1 { font-size: 23px; }
}

/* ---- 头像 ---- */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: middle;
  background: #e5e7eb;
}
.avatar.placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.avatar.big { width: 72px; height: 72px; font-size: 28px; }

.site-header a.who {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}
.nav-avatar { width: 24px; height: 24px; font-size: 11px; }

.profile { display: flex; gap: 16px; align-items: center; margin: 16px 0 24px; flex-wrap: wrap; }
.profile-info { display: grid; gap: 4px; }
.profile-info strong { font-size: 18px; }

/* ---- 图片预览 ---- */
.preview { display: flex; gap: 10px; flex-wrap: wrap; }
.preview:empty { display: none; }
.preview-item { margin: 0; width: 96px; }
.preview-item img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f3f4f6;
}
.preview-item figcaption { font-size: 12px; color: var(--muted); text-align: center; }

input[type="file"] {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafafa;
  width: 100%;
}
input[type="file"]::file-selector-button {
  font: inherit;
  font-size: 14px;
  margin-right: 10px;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

/* ---- 留言配图 ---- */
.messages .meta { align-items: center; }
.msg-images { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.msg-images img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f3f4f6;
  display: block;
}

/* ---- 相册 ---- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.shot {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  background: #f3f4f6;
}
.shot img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: transform .2s ease;
}
.shot:hover img { transform: scale(1.04); }
.shot .cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 6px 8px;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
}
.gallery-grid > .shot { position: relative; }

.shot-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.shot-card .shot { border-radius: 0; }
.shot-card figcaption { padding: 8px 10px; display: grid; gap: 4px; }
.shot-card .cap { font-size: 14px; word-break: break-word; }
.shot-card .by {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.upload-row { max-width: 520px; }
.more { font-size: 13px; font-weight: 400; margin-left: 8px; }
button.small { padding: 5px 10px; font-size: 13px; }

.thumb-row { display: flex; gap: 4px; }
.thumb-row img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f3f4f6;
}

/* ---- 留言详情 + 评论区 ---- */
.back-link {
  display: inline-block;
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
}
.back-link:hover { color: var(--accent); }

/* 首页每条留言底部的「💬 N 条评论」入口 */
.comment-count {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f4f6;
}
.comment-count:hover { background: #e5e7eb; color: var(--accent); }

/* 详情页正文 */
.detail .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.detail time { color: var(--muted); font-size: 13px; }
.detail-body {
  margin: 12px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 16px;
  line-height: 1.7;
}
.msg-images.big img { width: 200px; height: 200px; }
.detail-count { margin: 14px 0 0; }

.count-badge {
  display: inline-block;
  min-width: 22px;
  padding: 1px 7px;
  margin-left: 6px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  vertical-align: middle;
}

/* 发评论表单 */
.comment-form { margin-bottom: 24px; }
.comment-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  cursor: pointer;
}
.file-btn span {
  display: inline-block;
  padding: 8px 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafafa;
  font-size: 14px;
  color: var(--muted);
}
.file-btn:hover span { border-color: var(--accent); color: var(--accent); }

/* 评论列表 */
.empty-comments { margin-top: 20px; }
.comment-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.comment {
  display: flex;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.comment:last-child { border-bottom: 0; }
.comment-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 6px; }
.comment-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.comment-head strong { font-size: 14px; }
.comment-head time { color: var(--muted); font-size: 12px; }
.comment-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.6;
}
.comment-image { display: inline-block; }
.comment-image img {
  max-width: 180px;
  max-height: 180px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f3f4f6;
  display: block;
}
.link-danger {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--danger);
  cursor: pointer;
  text-decoration: underline;
}
.inline-form { margin: 0; }

@media (max-width: 600px) {
  .msg-images.big img { width: 100%; height: auto; max-height: 360px; }
  .comment-image img { max-width: 140px; max-height: 140px; }
}
