/* ── 变量 ── */
:root {
  --green:    #0E86B0;
  --green-d:  #075E7D;
  --green-l:  #DFF3FA;
  --green-xl: #F0FAFD;
  --amber:    #EF9F27;
  --red:      #E24B4A;
  --text:     #1a1a1a;
  --text-2:   #666;
  --text-3:   #999;
  --border:   #e8e8e8;
  --bg:       #f0f7fa;
  --white:    #ffffff;
  --topbar-h: 52px;
  --nav-h:    56px;
  --radius:   12px;
  --radius-s: 8px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  font-family: -apple-system, 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top);
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, textarea { font: inherit; color: inherit; border: none; outline: none; background: none; }
a { color: var(--green); text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── 顶栏 ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--green);
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%; padding: 0 12px;
}
.topbar-left { display: flex; align-items: center; gap: 4px; }
.topbar-title { font-size: 17px; font-weight: 600; color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.online-count {
  font-size: 12px; color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.18); border-radius: 20px;
  padding: 2px 8px;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  transition: background .15s;
}
.icon-btn:active { background: rgba(255,255,255,.2); }

/* ── 底部导航 ── */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; color: var(--text-3);
  position: relative;
  transition: color .15s;
}
.nav-item.active { color: var(--green); }
.nav-item svg { transition: transform .15s; }
.nav-item.active svg { transform: scale(1.1); }
.nav-badge {
  position: absolute; top: 6px; right: calc(50% - 18px);
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ── Main ── */
main {
  margin-top: calc(var(--topbar-h) + env(safe-area-inset-top));
  margin-bottom: var(--nav-h);
  min-height: calc(100vh - var(--topbar-h) - env(safe-area-inset-top) - var(--nav-h));
}
main.no-nav {
  margin-bottom: 0;
}

/* ── 页面居中（注册/登录/验证） ── */
.page-center {
  min-height: calc(100vh - var(--topbar-h));
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12px 16px 24px;
  background: var(--green-xl);
  overflow-y: auto;
}
.verify-card {
  width: 100%; max-width: 400px;
  background: var(--white); border-radius: 20px;
  padding: 24px 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  display: flex; flex-direction: column; gap: 12px;
}


.app-logo { text-align: center; }
.app-logo img { margin: 0 auto; border-radius: 20px; }
.app-name { text-align: center; font-size: 20px; font-weight: 700; color: var(--green-d); }
.app-tagline { text-align: center; font-size: 13px; color: var(--text-3); }
.success-mark {
  text-align: center; font-size: 48px; color: var(--green);
  line-height: 1;
}
.reg-title { text-align: center; font-size: 18px; font-weight: 600; }
.verify-box { display: flex; flex-direction: column; gap: 12px; }
.verify-hint { font-size: 14px; color: var(--text-2); text-align: center; }
.verify-login-hint { font-size: 13px; color: var(--text-3); text-align: center; }

/* 音频播放器 */
.audio-player {
  display: flex; align-items: center; gap: 10px;
  background: var(--green-l); border-radius: var(--radius-s);
  padding: 10px 14px;
}
.play-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform .1s;
}
.play-btn:active { transform: scale(.92); }
.audio-wave {
  flex: 1; display: flex; align-items: center; gap: 3px; height: 24px;
}
.audio-wave span {
  flex: 1; background: var(--green); border-radius: 2px; opacity: .6;
  animation: wave 1.2s ease-in-out infinite;
}
.audio-wave span:nth-child(1) { height: 4px; animation-delay: 0s; }
.audio-wave span:nth-child(2) { height: 12px; animation-delay: .1s; }
.audio-wave span:nth-child(3) { height: 18px; animation-delay: .2s; }
.audio-wave span:nth-child(4) { height: 10px; animation-delay: .3s; }
.audio-wave span:nth-child(5) { height: 16px; animation-delay: .4s; }
.audio-wave span:nth-child(6) { height: 8px;  animation-delay: .5s; }
.audio-wave span:nth-child(7) { height: 14px; animation-delay: .35s; }
.audio-wave span:nth-child(8) { height: 6px;  animation-delay: .25s; }
.audio-wave span:nth-child(9) { height: 12px; animation-delay: .15s; }
.audio-wave span:nth-child(10){ height: 4px;  animation-delay: .05s; }
.audio-wave.paused span { animation-play-state: paused; height: 4px !important; }
@keyframes wave {
  0%, 100% { transform: scaleY(1); }
  50%       { transform: scaleY(.4); }
}
.audio-dur { font-size: 12px; color: var(--green-d); white-space: nowrap; }

/* 表单 */
.field {
  width: 100%; padding: 12px 14px;
  background: var(--bg); border-radius: var(--radius-s);
  border: 1.5px solid transparent;
  font-size: 15px;
  transition: border-color .15s;
}
.field:focus { border-color: var(--green); background: var(--white); }
.btn-primary {
  width: 100%; padding: 13px;
  background: var(--green); color: #fff;
  border-radius: var(--radius-s); font-size: 16px; font-weight: 600;
  transition: opacity .15s, transform .1s;
}
.btn-primary:active { opacity: .85; transform: scale(.98); }
.btn-primary:disabled { opacity: .5; }
.btn-ghost {
  padding: 10px 20px; border-radius: var(--radius-s);
  border: 1.5px solid var(--border); color: var(--text-2);
  font-size: 14px;
  transition: background .15s;
}
.btn-ghost:active { background: var(--bg); }
.err-msg { font-size: 13px; color: var(--red); text-align: center; min-height: 18px; }

/* ── 帖子广场 ── */
.posts-page { padding-bottom: 8px; }
.posts-list { display: flex; flex-direction: column; gap: 0; }
.load-more-wrap { padding: 16px; text-align: center; }
.loading-spinner { text-align: center; padding: 40px; color: var(--text-3); font-size: 14px; }

.post-card {
  background: var(--white);
  border-bottom: 8px solid var(--bg);
  padding: 14px 16px;
}
.post-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--green-l); color: var(--green-d);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600;
}
.post-meta { display: flex; flex-direction: column; gap: 2px; }
.post-name { font-size: 14px; font-weight: 600; }
.post-time { font-size: 12px; color: var(--text-3); }
.post-content { font-size: 15px; line-height: 1.6; margin-bottom: 10px; word-break: break-all; }
.post-content:empty { display: none; }
.post-media { margin-bottom: 10px; }
.post-media:empty { display: none; }
.post-media img { width: 100%; border-radius: var(--radius-s); max-height: 320px; object-fit: cover; }
.post-media video { width: 100%; border-radius: var(--radius-s); max-height: 320px; }
.post-actions { display: flex; gap: 16px; align-items: center; }
.act-btn {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--text-3);
  padding: 4px 0;
  transition: color .15s;
}
.act-btn:active { color: var(--green); }
.voice-reply-btn { margin-left: auto; }

/* 回复区 */
.replies-section {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.reply-item {
  display: flex; gap: 8px;
}
.reply-item .avatar { width: 28px; height: 28px; font-size: 12px; }
.reply-body { flex: 1; }
.reply-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.reply-text { font-size: 14px; line-height: 1.5; }
.reply-time { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* 语音气泡 */
.voice-bubble {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--green-l); border-radius: 16px;
  padding: 7px 12px; cursor: pointer;
  transition: background .15s;
}
.voice-bubble:active { background: #c5eadb; }
.voice-bubble .play-btn { width: 28px; height: 28px; }
.voice-wave {
  display: flex; align-items: center; gap: 2px; width: 48px; height: 16px;
}
.voice-wave span {
  flex: 1; background: var(--green); border-radius: 1px; opacity: .7;
}
.voice-dur-label { font-size: 12px; color: var(--green-d); }

/* 回复输入框 */
.reply-input-row {
  margin-top: 12px; display: flex; gap: 8px; align-items: center;
}
.reply-text-input {
  flex: 1; background: var(--bg); border-radius: 20px;
  padding: 9px 14px; font-size: 14px;
  border: 1.5px solid transparent;
  transition: border-color .15s;
}
.reply-text-input:focus { border-color: var(--green); background: #fff; }
.reply-send-btn {
  padding: 8px 14px; background: var(--green); color: #fff;
  border-radius: 20px; font-size: 14px; font-weight: 500;
}

/* ── 发帖页 ── */
.compose-page {
  min-height: calc(100vh - var(--topbar-h) - var(--nav-h));
  background: var(--white);
  display: flex; flex-direction: column;
}
.compose-textarea {
  flex: 1; width: 100%; padding: 16px;
  font-size: 16px; line-height: 1.7; resize: none;
  min-height: 200px;
}
.compose-media-preview {
  padding: 0 16px 8px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.compose-media-preview img,
.compose-media-preview video {
  width: 100px; height: 100px; object-fit: cover;
  border-radius: var(--radius-s);
}
.compose-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.compose-toolbar .icon-btn { color: var(--text-2); }
.compose-send { margin-left: auto; width: auto; padding: 10px 20px; }

/* ── 聊天室 ── */
.chat-page {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-h) - var(--nav-h));
  position: relative;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--bg);
  overscroll-behavior: contain;
}
.chat-input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--white);
  border-top: 1px solid var(--border);
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.chat-text-input {
  flex: 1; background: var(--bg); border-radius: 20px;
  padding: 9px 14px; font-size: 15px;
  border: 1.5px solid transparent;
  transition: border-color .15s;
}
.chat-text-input:focus { border-color: var(--green); background: #fff; }
.mic-btn, .send-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--green); color: #fff;
  flex-shrink: 0;
  transition: transform .1s;
}
.mic-btn:active, .send-btn:active { transform: scale(.9); }
.mic-btn.recording { background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.1); }
}

/* 消息气泡 */
.msg-row { display: flex; gap: 8px; align-items: flex-end; }
.msg-row.me { flex-direction: row-reverse; }
.msg-row .avatar { width: 32px; height: 32px; font-size: 13px; flex-shrink: 0; }
.msg-bubble-wrap { display: flex; flex-direction: column; gap: 3px; max-width: 72%; }
.msg-row.me .msg-bubble-wrap { align-items: flex-end; }
.msg-sender { font-size: 12px; color: var(--text-3); padding: 0 4px; }
.msg-bubble {
  background: var(--white); border-radius: 16px 16px 16px 4px;
  padding: 9px 13px; font-size: 15px; line-height: 1.5;
  word-break: break-all;
}
.msg-row.me .msg-bubble {
  background: var(--green); color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.msg-time { font-size: 11px; color: var(--text-3); padding: 0 4px; }
.system-msg {
  text-align: center; font-size: 12px; color: var(--text-3);
  padding: 4px 0;
}

/* 录音浮层（聊天室） */
.recording-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border-radius: 20px 20px 0 0;
}
.rec-indicator { display: flex; align-items: center; gap: 10px; }
.rec-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--red);
  animation: blink 1s step-start infinite;
}
@keyframes blink { 50% { opacity: 0; } }
#rec-timer { color: #fff; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-hint { color: rgba(255,255,255,.8); font-size: 14px; }

/* 语音录制浮层（帖子回复） */
.voice-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.voice-modal {
  background: var(--white); border-radius: 24px;
  padding: 40px 48px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  min-width: 240px;
}
.rec-big-dot {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--green);
  animation: pulse 1s infinite;
}
.rec-big-dot.cancel { background: var(--red); }
.rec-time { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.rec-tip { font-size: 14px; color: var(--text-3); }
.rec-cancel-btn {
  padding: 10px 24px; border-radius: 20px;
  border: 1.5px solid var(--border); color: var(--text-2);
  font-size: 14px;
}

/* ── 个人页 ── */
.profile-page { background: var(--white); min-height: 100%; }
.profile-hero {
  background: linear-gradient(160deg, var(--green-l) 0%, var(--white) 100%);
  padding: 40px 20px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700;
}
.profile-name { font-size: 20px; font-weight: 700; }
.profile-phone { font-size: 14px; color: var(--text-3); }
.profile-menu { padding: 16px; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px 16px;
  border-radius: var(--radius); font-size: 15px; color: var(--red);
  transition: background .15s;
}
.menu-item:active { background: var(--bg); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.8); color: #fff;
  padding: 10px 18px; border-radius: 24px; font-size: 14px;
  opacity: 0; pointer-events: none; z-index: 500;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 管理后台 ── */
.admin-page { background: var(--white); min-height: 100%; }
.admin-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--border); border-bottom: 1px solid var(--border);
}
.stat-card {
  background: var(--white); padding: 16px 8px; text-align: center;
}
.stat-num { font-size: 24px; font-weight: 700; color: var(--green); }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.admin-search-wrap { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.admin-user-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  gap: 12px;
}
.admin-user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.admin-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--green-l); color: var(--green-d);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600;
}
.admin-user-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.admin-user-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.admin-user-actions { display: flex; gap: 6px; flex-shrink: 0; }
.admin-btn {
  padding: 5px 10px; border-radius: 6px; font-size: 12px; font-weight: 500;
  border: 1px solid transparent;
}
.admin-btn-amber { background: #FEF3C7; color: #92400E; border-color: #FCD34D; }
.admin-btn-green  { background: #D1FAE5; color: #065F46; border-color: #6EE7B7; }
.admin-btn-red   { background: #FEE2E2; color: #991B1B; border-color: #FCA5A5; }
.badge-banned {
  font-size: 11px; background: #FEE2E2; color: #991B1B;
  padding: 1px 6px; border-radius: 4px; font-weight: 400;
}
.badge-admin {
  font-size: 11px; background: var(--green-l); color: var(--green-d);
  padding: 1px 6px; border-radius: 4px; font-weight: 400;
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
.app-version { text-align: center; font-size: 11px; color: var(--text-3); margin-top: 4px; }
