/* ============ 校园需求墙 全局样式 ============ */
:root {
  --primary: #C8102E;        /* 东华大学红 */
  --primary-dark: #A50D25;
  --primary-light: #FCE9EC;
  --green: #2e9e6b;
  --green-light: #e6f6ee;
  --orange: #e8963a;
  --orange-light: #fdf3e3;
  --red: #e05252;
  --red-light: #fdecec;
  --purple: #8a63d2;
  --purple-light: #f1ebfc;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #232a35;
  --text-2: #5c6675;
  --text-3: #98a2b3;
  --border: #e6e9ef;
  --shadow: 0 2px 10px rgba(30, 50, 90, 0.06);
  --shadow-lg: 0 10px 30px rgba(30, 50, 90, 0.12);
  --radius: 14px;
}

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }

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

/* ============ 顶栏 ============ */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  /* 非吸顶：随页面滚动，避免一直停留在顶部 */
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 8px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-logo { font-size: 26px; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: 0.5px; }
.brand-slogan { font-size: 12px; color: var(--text-3); margin-left: 4px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; cursor: pointer;
  font-size: 14px; font-family: inherit;
  padding: 8px 18px; border-radius: 999px;
  transition: all 0.15s;
  background: var(--border); color: var(--text);
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 13px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ============ 主区域 ============ */
.main { flex: 1; padding: 24px 20px 48px; }

/* ============ 首页布局 ============ */
.home-layout { display: grid; grid-template-columns: 230px 1fr; gap: 20px; align-items: start; }
@media (max-width: 820px) { .home-layout { grid-template-columns: 1fr; } }

/* 侧边栏（基础规则放在移动端断点之前，避免被媒体查询覆盖；非吸顶跟随滚动） */
.sidebar { position: static; }

/* 手机端横向分类 chips（桌面隐藏） */
.cat-chips { display: none; }

/* 桌面端隐藏底部导航（基础规则放在媒体查询之前，避免被手机断点覆盖） */
.bottom-nav { display: none; }

.side-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.side-title { font-size: 14px; font-weight: 700; color: var(--text-2); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.cat-list { display: flex; flex-direction: column; gap: 2px; }
.cat-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
  color: var(--text-2); font-size: 14px; transition: all 0.12s;
  border: none; background: none; font-family: inherit; width: 100%; text-align: left;
}
.cat-item:hover { background: var(--bg); color: var(--text); }
.cat-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.cat-item .count { font-size: 12px; color: var(--text-3); }
.cat-emoji { margin-right: 8px; }

.stats-box { display: flex; justify-content: space-between; text-align: center; }
.stats-box .num { font-size: 20px; font-weight: 700; color: var(--primary); }
.stats-box .label { font-size: 12px; color: var(--text-3); }

/* 搜索 + 排序 */
.list-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box {
  flex: 1; min-width: 220px; display: flex; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 0 6px 0 16px; height: 42px; box-shadow: var(--shadow);
}
.search-box input { flex: 1; border: none; outline: none; font-size: 14px; font-family: inherit; background: transparent; color: var(--text); }
.search-box .btn { border-radius: 999px; }
.sort-tabs { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.sort-tab {
  border: none; background: none; padding: 8px 18px; cursor: pointer;
  font-size: 14px; color: var(--text-2); font-family: inherit; transition: all 0.12s;
}
.sort-tab.active { background: var(--primary); color: #fff; }

/* 帖子卡片 */
.post-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 14px; cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  border: 1px solid transparent;
}
.post-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary-light); }
.post-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 2px 10px; border-radius: 999px; font-weight: 600; }
.badge-cat { background: var(--primary-light); color: var(--primary); }
.badge-tag { background: var(--green-light); color: var(--green); }
.badge-status-closed { background: var(--text-3); color: #fff; }
.badge-status-open { background: var(--orange-light); color: var(--orange); }
.post-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.post-title:hover { color: var(--primary); }
.post-excerpt { color: var(--text-2); font-size: 14px; margin-bottom: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-meta { display: flex; align-items: center; gap: 14px; color: var(--text-3); font-size: 13px; flex-wrap: wrap; }
.post-meta .author { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--primary-light); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.avatar-sm { width: 22px; height: 22px; font-size: 12px; }
.meta-icon { margin-right: 3px; }

/* 分页 */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 24px; }
.page-btn {
  min-width: 36px; height: 36px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); cursor: pointer;
  font-size: 14px; font-family: inherit; color: var(--text-2); transition: all 0.12s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ 表单 / 认证卡片 ============ */
.auth-wrap { max-width: 460px; margin: 40px auto 0; }
.form-card {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 32px 34px;
}
.form-card h1 { font-size: 22px; margin-bottom: 6px; }
.form-card .sub { color: var(--text-3); font-size: 13px; margin-bottom: 22px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.form-control {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit; background: #fbfcfe;
  transition: border-color 0.12s, box-shadow 0.12s; color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 125, 221, 0.12); background: #fff; }
textarea.form-control { resize: vertical; min-height: 120px; line-height: 1.7; }
select.form-control { appearance: auto; }
.code-row { display: flex; gap: 10px; }
.code-row .form-control { flex: 1; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-tip { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.form-error { background: var(--red-light); color: var(--red); padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; display: none; }
.form-success { background: var(--green-light); color: var(--green); padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; display: none; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-3); }

.demo-tip {
  background: var(--orange-light); border: 1px dashed var(--orange);
  color: #9c6219; border-radius: 10px; padding: 10px 14px; font-size: 12.5px; margin-bottom: 16px; line-height: 1.7;
}

/* ============ 帖子详情 ============ */
.detail-wrap { max-width: 860px; margin: 0 auto; }
.detail-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 30px 34px; margin-bottom: 16px; }
.detail-head { margin-bottom: 18px; }
.detail-cats { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.detail-title { font-size: 24px; font-weight: 800; line-height: 1.4; margin-bottom: 14px; }
.detail-author { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.detail-author .avatar { width: 42px; height: 42px; font-size: 22px; }
.detail-author .name { font-weight: 600; }
.detail-author .college { font-size: 12.5px; color: var(--text-3); }
.detail-stats { margin-left: auto; text-align: right; font-size: 13px; color: var(--text-3); }
.detail-content { padding: 22px 0; font-size: 15.5px; line-height: 1.9; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.detail-actions { display: flex; gap: 12px; }
.like-btn { background: var(--red-light); color: var(--red); }
.like-btn.liked { background: var(--red); color: #fff; }

.comments-section { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 24px 28px; }
.comments-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.comment-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment-item:last-child { border-bottom: none; }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.comment-head .name { font-weight: 600; font-size: 14px; }
.comment-head .college { font-size: 12px; color: var(--text-3); }
.comment-head .time { font-size: 12px; color: var(--text-3); margin-left: auto; }
.comment-body { font-size: 14.5px; color: var(--text); }
.comment-form { margin-top: 18px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-state .emoji { font-size: 48px; display: block; margin-bottom: 12px; }

/* ============ 用户中心 ============ */
.profile-head { display: flex; align-items: center; gap: 20px; background: linear-gradient(135deg, #C8102E, #8a1a2b); color: #fff; border-radius: 18px; padding: 28px 32px; margin-bottom: 20px; box-shadow: var(--shadow-lg); }
.profile-avatar { width: 72px; height: 72px; border-radius: 50%; background: rgba(255,255,255,0.22); display: flex; align-items: center; justify-content: center; font-size: 38px; }
.profile-name { font-size: 22px; font-weight: 700; }
.profile-info { font-size: 13.5px; opacity: 0.92; margin-top: 4px; }
.verified-badge { background: rgba(255,255,255,0.25); font-size: 12px; padding: 2px 10px; border-radius: 999px; margin-left: 10px; vertical-align: middle; }

/* ============ 发帖 ============ */
.publish-wrap { max-width: 760px; margin: 0 auto; }
.tag-hint { color: var(--text-3); font-size: 12px; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #232a35; color: #fff; padding: 11px 24px; border-radius: 999px;
  font-size: 14px; z-index: 999; opacity: 0; transition: all 0.25s; pointer-events: none;
  box-shadow: var(--shadow-lg); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }

/* ============ 加载 ============ */
.loading { text-align: center; padding: 80px 0; color: var(--text-3); }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; margin: 0 auto 14px; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 页脚 ============ */
.footer { border-top: 1px solid var(--border); padding: 18px 0; text-align: center; color: var(--text-3); font-size: 12.5px; background: var(--card); }

/* ============ 移动端适配（手机优先）放在文件末尾，确保最高优先级 ============ */
@media (max-width: 820px) {
  .brand-slogan { display: none; }
  .topbar-inner { height: 52px; min-height: 52px; flex-wrap: wrap; padding: 6px 0; }
  .brand-name { font-size: 16px; }
  .container { padding: 0 14px; }
  .main { padding: 12px 14px 76px; } /* 底部留出导航栏空间 */

  /* 顶栏：手机端隐藏"发布需求"按钮（底部导航有），减少拥挤 */
  .topbar-publish { display: none; }
  .topbar-logout { padding: 5px 10px !important; min-height: 30px !important; font-size: 12.5px !important; }
  .topbar-profile-hint { padding: 5px 10px !important; min-height: 30px !important; font-size: 12.5px !important; }
  .topbar-actions .btn { padding: 7px 12px; min-height: 34px; }

  /* 侧边栏隐藏，改用横向分类 chips */
  .sidebar { display: none; }
  .cat-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0 12px;
    margin-bottom: 4px;
    scrollbar-width: none;
  }
  .cat-chips::-webkit-scrollbar { display: none; }
  .cat-chips .cat-item {
    flex: 0 0 auto;
    width: auto;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    white-space: nowrap;
    font-size: 13.5px;
    min-height: 38px;
  }
  .cat-chips .cat-item.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
  }

  .post-card { padding: 14px 16px; margin-bottom: 10px; }
  .post-title { font-size: 16px; }
  .post-excerpt { font-size: 13.5px; -webkit-line-clamp: 2; }
  .detail-card { padding: 20px 18px; }
  .comments-section { padding: 18px 16px; }
  .form-card { padding: 24px 20px; }
  .form-row { grid-template-columns: 1fr; }
  .detail-title { font-size: 19px; }
  .detail-stats { display: none; }
  .profile-head { flex-direction: column; text-align: center; padding: 22px 18px; }
  .list-head { gap: 8px; }
  .search-box { height: 40px; }
  .btn { padding: 9px 16px; min-height: 40px; } /* 触控区域 ≥ 40px */

  /* 底部导航（手机显示，桌面隐藏） */
  .footer { display: none; }
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--card);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-3);
    font-size: 11px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .bn-item.active { color: var(--primary); font-weight: 600; }
  .bn-icon { font-size: 20px; line-height: 1; }
  .bn-item.active .bn-icon { transform: scale(1.08); }

  /* 帖子卡片触控反馈 */
  .post-card { -webkit-tap-highlight-color: rgba(59,125,221,0.12); }
  .post-card:active { transform: scale(0.985); }

  /* 详情页操作按钮手机全宽排布 */
  .detail-actions { flex-wrap: wrap; }
  .detail-actions .btn { flex: 1 1 45%; justify-content: center; min-height: 44px; }

  /* 评论/表单输入字号 ≥16px 防止 iOS 聚焦缩放 */
  .form-control, .search-box input, textarea.form-control { font-size: 16px; }

  /* 分页按钮触控 */
  .page-btn { min-width: 40px; height: 40px; }
}

/* ============ 结构化信息卡（快递代拿/食堂点餐） ============ */
.extra-box {
  background: var(--green-light);
  border: 1px solid rgba(46, 158, 107, 0.25);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.extra-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 12px;
}
.extra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 16px;
}
.extra-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.extra-label {
  font-size: 12px;
  color: var(--text-3);
}
.extra-value {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}
