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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #f7f8fa;
  color: #1f2328;
  line-height: 1.6;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

h1 {
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.card {
  background: #fff;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: #555;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.7rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 1rem;
}

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

button {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.8rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

button:disabled { opacity: 0.5; cursor: not-allowed; }

button.danger {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.msg {
  margin-top: 1rem;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
  display: none;
}
.msg.error { background: #ffe0e0; color: #c0392b; display: block; }
.msg.success { background: #e0f7e9; color: #1e8a49; display: block; }

.muted { color: #888; font-size: 0.85rem; margin-top: 1rem; text-align: center; }
.muted a { color: #667eea; }

/* ------- 时间线相关 ------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e6e8eb;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand {
  font-weight: 600;
  font-size: 1.1rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-decoration: none;
}
.topbar-link {
  color: #555;
  text-decoration: none;
  font-size: 0.9rem;
}
.topbar-link:hover { color: #667eea; }

.feed {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.composer {
  margin-bottom: 1.5rem;
  padding: 1rem;
}
.composer textarea {
  width: 100%;
  min-height: 80px;
  padding: 0.7rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 1rem;
  resize: vertical;
  font-family: inherit;
}
.composer textarea:focus {
  outline: none;
  border-color: #667eea;
}
.composer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.7rem;
}
.counter { color: #888; font-size: 0.8rem; }
.btn-primary {
  margin-top: 0 !important;
  width: auto;
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
}

.post {
  margin-bottom: 1rem;
  padding: 1rem;
}
.post-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
}
.post-meta { flex: 1; }
.post-author { font-weight: 600; font-size: 0.95rem; }
.post-time { color: #888; font-size: 0.8rem; }
.post-delete {
  margin-top: 0 !important;
  width: auto;
  padding: 0.3rem 0.7rem;
  background: transparent;
  color: #888;
  font-size: 0.8rem;
  border: 1px solid #e6e8eb;
}
.post-delete:hover { color: #c0392b; border-color: #f0c0c0; }
.post-content {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 0.95rem;
  color: #1f2328;
}

/* ------- 发图相关 ------- */
.img-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.8rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #555;
  cursor: pointer;
  background: #fff;
}
.img-btn:hover { color: #667eea; border-color: #667eea; }

.previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.5rem;
  margin-top: 0.7rem;
}
.preview {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: #f0f1f3;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  color: #888;
}
.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview .rm {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px;
  margin: 0; padding: 0;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  color: #fff; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.preview.err { background: #ffe0e0; color: #c0392b; }

/* 图片网格 */
.post-images {
  display: grid;
  gap: 4px;
  margin-top: 0.8rem;
  border-radius: 8px;
  overflow: hidden;
}
.post-images .post-img {
  position: relative;
  aspect-ratio: 1;
  cursor: zoom-in;
  background: #f0f1f3;
}
.post-images.single .post-img {
  aspect-ratio: auto;
  max-height: 500px;
}
.post-images.single img {
  width: 100%;
  height: auto;
  max-height: 500px;
  object-fit: contain;
}
.post-images .post-img img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.post-images.grid-2 { grid-template-columns: 1fr 1fr; }
.post-images.grid-3,
.post-images.grid-5,
.post-images.grid-6 { grid-template-columns: repeat(3, 1fr); }
.post-images.grid-4 { grid-template-columns: repeat(2, 1fr); }
.post-images.grid-7,
.post-images.grid-8,
.post-images.grid-9 { grid-template-columns: repeat(3, 1fr); }

/* ------- Lightbox ------- */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  cursor: zoom-out;
  padding: 1rem;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ------- 评论 ------- */
.post-actions {
  margin-top: 0.8rem;
  padding-top: 0.6rem;
  border-top: 1px solid #f0f1f3;
}
.comments-toggle {
  margin-top: 0 !important;
  width: auto;
  padding: 0.3rem 0.7rem;
  background: transparent;
  color: #555;
  font-size: 0.85rem;
  border: 1px solid #e6e8eb;
}
.comments-toggle:hover { color: #667eea; border-color: #667eea; }
.comments-toggle .cnt { color: #888; margin-left: 0.2rem; }

.comments {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid #f0f1f3;
}
.comments-list { display: flex; flex-direction: column; gap: 0.8rem; }

.comment { display: flex; gap: 0.6rem; }
.cmt-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.cmt-body { flex: 1; min-width: 0; }
.cmt-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
}
.cmt-author { font-weight: 600; color: #1f2328; }
.cmt-time { color: #888; font-size: 0.75rem; }
.cmt-delete {
  margin: 0 0 0 auto !important;
  width: auto;
  padding: 0.15rem 0.5rem;
  background: transparent;
  color: #888;
  font-size: 0.75rem;
  border: 1px solid #e6e8eb;
}
.cmt-delete:hover { color: #c0392b; border-color: #f0c0c0; }
.cmt-text {
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #1f2328;
}
.cmt-img {
  margin-top: 0.4rem;
  max-width: 200px;
  border-radius: 6px;
  overflow: hidden;
  cursor: zoom-in;
  background: #f0f1f3;
}
.cmt-img img { width: 100%; height: auto; display: block; }

.cmt-composer {
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px dashed #e6e8eb;
}
.cmt-text-input {
  width: 100%;
  min-height: 50px;
  padding: 0.5rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 0.9rem;
  resize: vertical;
  font-family: inherit;
}
.cmt-text-input:focus { outline: none; border-color: #667eea; }
.cmt-preview-box {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.cmt-preview-box:empty { display: none; }
.cmt-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}
.cmt-msg { margin-top: 0.5rem; font-size: 0.8rem; }

.small {
  margin-top: 0 !important;
  width: auto;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
}

/* ------- 板块 tab ------- */
#board-bar { margin-bottom: 1rem; }
.board-tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.3rem 0;
}
.board-tab {
  margin-top: 0 !important;
  width: auto;
  flex-shrink: 0;
  padding: 0.4rem 0.9rem;
  background: #fff;
  color: #555;
  border: 1px solid #e6e8eb;
  border-radius: 999px;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}
.board-tab:hover { color: #667eea; border-color: #c5cae8; }
.board-tab.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-color: transparent;
}
.board-tab-count {
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  color: inherit;
}
.board-tab.active .board-tab-count { background: rgba(255, 255, 255, 0.25); }
.board-tab-add {
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.35rem 0.7rem;
  color: #888;
}
.board-tab-add:hover { color: #667eea; }

/* ------- 管理后台 ------- */
.admin-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.tab-btn {
  margin-top: 0 !important;
  width: auto;
  padding: 0.5rem 1rem;
  background: #fff;
  color: #555;
  border: 1px solid #e6e8eb;
  font-size: 0.9rem;
}
.tab-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-color: transparent;
}

.invites-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
}
.invites-head .msg { margin: 0; flex: 1; font-size: 0.85rem; }

.invite-list, .user-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.invite-list .loading, .invite-list .empty,
.user-list .loading, .user-list .empty {
  color: #888;
  text-align: center;
  padding: 1.5rem;
  font-size: 0.9rem;
}

.invite {
  padding: 0.8rem;
  border: 1px solid #e6e8eb;
  border-radius: 8px;
}
.invite.is-used { opacity: 0.6; }
.invite-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}
.invite-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1rem;
  font-weight: 600;
  background: #f3f4f6;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}
.copy-btn { background: #fff; color: #555; border: 1px solid #d0d7de; }
.copy-btn:hover { color: #667eea; border-color: #667eea; }
.invite-meta {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #888;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}
.invite-meta .used { color: #1e8a49; }
.invite-meta .unused { color: #c08a00; }

.user-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem;
  border: 1px solid #e6e8eb;
  border-radius: 8px;
}
.small-avatar { width: 36px; height: 36px; font-size: 0.85rem; }
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.user-meta { font-size: 0.8rem; color: #888; margin-top: 0.15rem; }
.tag {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
}
.tag.admin { background: #eef2ff; color: #4f46e5; }
.tag.banned { background: #ffe0e0; color: #c0392b; }
.tag.me { background: #e0f7e9; color: #1e8a49; }
.user-actions { flex-shrink: 0; }
button.danger.small {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.board-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.board-form input {
  padding: 0.5rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 0.9rem;
}
.board-form input:focus { outline: none; border-color: #667eea; }
.board-form #bd-desc { grid-column: 1 / -1; }
.board-form .btn-primary { grid-column: 1 / -1; margin-top: 0 !important; }

.board-admin-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.board-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem;
  border: 1px solid #e6e8eb;
  border-radius: 8px;
}
.board-info { flex: 1; min-width: 0; }
.board-row-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}
.board-slug {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: #f3f4f6;
  color: #555;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.8rem;
}
.board-row-title { font-weight: 600; }
.board-row-desc { color: #666; font-size: 0.85rem; margin-top: 0.2rem; }
.board-row-meta { color: #888; font-size: 0.8rem; margin-top: 0.2rem; }
