/* WHU二手书市 网页版 · 视觉升级版 */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei', sans-serif;
  background: #eef1f4; color: #232a30; font-size: 14px;
  max-width: 520px; margin: 0 auto; min-height: 100vh;
  display: flex; flex-direction: column;
}
#app { display: flex; flex-direction: column; min-height: 100vh; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

:root {
  --brand: #0f8a5f;
  --brand-2: #16a06f;
  --brand-soft: #e3f4ec;
  --ink: #232a30;
  --sub: #5a6570;
  --light: #98a1a8;
  --line: #e6eaee;
}

/* ---------- 顶栏：渐变 + 装饰 ---------- */
#topbar {
  background:
    radial-gradient(circle at 85% -20%, rgba(255,255,255,.16) 0 60px, transparent 61px),
    radial-gradient(circle at 8% 120%, rgba(255,255,255,.12) 0 46px, transparent 47px),
    linear-gradient(135deg, #0d7a54, #12a06f);
  color: #fff;
  padding: calc(16px + env(safe-area-inset-top)) 18px 22px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
  border-radius: 0 0 26px 26px;
}
#topbar-title { font-size: 19px; font-weight: 800; letter-spacing: 1px; display: flex; align-items: center; gap: 9px; }
#topbar-title::before {
  content: ''; width: 34px; height: 34px;
  background: url('/appicon.png') center/contain no-repeat;
}
#bell { background: none; color: #fff; font-size: 21px; position: relative; padding: 4px; }
.badge {
  position: absolute; top: -7px; right: -11px;
  background: #ff5a4e; color: #fff; font-size: 10px; font-style: normal;
  min-width: 17px; height: 17px; line-height: 17px; border-radius: 9px;
  padding: 0 4px; text-align: center; font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
#tabbar .badge { top: -3px; right: -8px; }

/* ---------- 视图区 ---------- */
#view { flex: 1; padding: 16px 14px 92px; }
#view.flush { padding: 14px 14px 90px; }
.row { display: flex; gap: 8px; align-items: center; }
.row .grow { flex: 1; min-width: 0; }

/* 搜索胶囊（书市页） */
.search-card { padding: 14px; }
.search-row { display: flex; gap: 9px; align-items: center; }
.search-ico { width: 18px; height: 18px; color: var(--light); flex-shrink: 0; margin-left: 12px; }
.search-row input {
  flex: 1; min-width: 0; border: none; background: #f1f4f6;
  border-radius: 12px; padding: 11px 12px 11px 2px; font-size: 14px; color: var(--ink);
}
.search-row input:focus { outline: none; background: #eaf0ee; }
.search-row input::placeholder { color: #a8b0b6; }
.search-row button {
  flex-shrink: 0; border: none; color: #fff; font-weight: 700; font-size: 14px;
  padding: 11px 18px; border-radius: 12px;
  background: linear-gradient(135deg, #14a871, #0d8a5f);
  box-shadow: 0 4px 12px rgba(15,138,95,.28);
}

/* ---------- 卡片 ---------- */
.card {
  background: #fff; border-radius: 18px; padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 4px 18px rgba(30, 50, 42, .07);
}
h2.sec { font-size: 16px; font-weight: 800; margin: 6px 4px 12px; }
.muted { color: var(--light); font-size: 12px; }
.sub { color: var(--sub); font-size: 12px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 7px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(22, 160, 111, .14);
}

/* ---------- 按钮 ---------- */
.btn {
  display: block; width: 100%; padding: 13px 0; border-radius: 13px;
  background: linear-gradient(135deg, #14a871, #0d8a5f); color: #fff;
  font-size: 15.5px; font-weight: 700; letter-spacing: 1px;
  box-shadow: 0 6px 16px rgba(15, 138, 95, .3);
  transition: transform .12s, box-shadow .12s;
}
.btn:active { transform: scale(.97); box-shadow: 0 2px 8px rgba(15,138,95,.25); }
.btn:disabled { opacity: .55; }
.btn.ghost { background: #fff; color: var(--sub); border: 1.5px solid var(--line); font-weight: 500; box-shadow: none; }
.btn.danger { background: #fdeeec; color: #c0392b; font-weight: 600; box-shadow: none; }
.btn.small { width: auto; padding: 8px 15px; font-size: 13px; border-radius: 10px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 15px; border-radius: 17px; background: #eceff2;
  color: var(--sub); font-size: 12.5px; border: none; transition: all .15s;
}
.chip.on { background: var(--brand); color: #fff; font-weight: 600; }
.chip.small { padding: 5px 11px; font-size: 11px; border-radius: 12px; }

/* ---------- 书列表卡片 ---------- */
.book-card {
  display: flex; gap: 12px; background: #fff; border-radius: 18px;
  padding: 13px; margin-bottom: 12px;
  box-shadow: 0 4px 18px rgba(30, 50, 42, .07);
  cursor: pointer; transition: transform .12s;
}
.book-card:active { transform: scale(.985); }
.cover {
  width: 76px; height: 98px; border-radius: 12px; object-fit: cover; flex-shrink: 0;
  background: #eff3fa; display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #b9c4d4;
}
.bc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bc-title { font-size: 15.5px; font-weight: 800; color: var(--ink); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.bc-note { color: var(--sub); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-meta { color: var(--light); font-size: 11px; margin-top: auto; padding-top: 4px; }
.bc-price { font-size: 17px; font-weight: 800; color: var(--brand); white-space: nowrap; align-self: flex-start; }
.bc-price.small { font-size: 12px; line-height: 1.5; max-width: 120px; }
.tag { display: inline-block; background: var(--brand-soft); color: var(--brand); border-radius: 10px; padding: 2.5px 9px; font-size: 11px; margin-right: 5px; font-weight: 600; }
.tag.gray { background: #eef0f3; color: #9aa3a8; font-weight: 500; }
.tag.red { background: #fdeeec; color: #c0392b; }

/* ---------- 详情页 ---------- */
.detail-cover {
  width: calc(100% + 28px); margin: -14px 0 0 -14px;
  background: linear-gradient(180deg, #dfe9e3, #eff3fa);
  display: flex; align-items: center; justify-content: center;
  font-size: 64px; color: #b9c4d4; overflow: hidden; min-height: 120px;
}
.detail-cover img { width: 100%; max-height: 340px; object-fit: contain; }
.d-title { font-size: 21px; font-weight: 800; margin: 12px 2px 6px; line-height: 1.3; }
.d-price { color: var(--brand); font-weight: 800; }
.d-price.big { font-size: 23px; }
.d-note { font-size: 14.5px; line-height: 1.7; color: var(--brand); font-weight: 700; }
.seller-card { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 46px; height: 46px; border-radius: 23px; background: linear-gradient(135deg, #14a871, #0d8a5f);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.tips-card { background: linear-gradient(135deg, #fff8e8, #fdf3d8) !important; border-radius: 14px !important; }
.tips-card .sub { color: #8a6d3b; line-height: 1.7; }

/* ---------- 聊天 ---------- */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 200px); min-height: 300px; }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 2px; }
.msg { display: flex; margin-bottom: 10px; }
.msg.me { justify-content: flex-end; }
.bubble {
  max-width: 76%; padding: 10px 13px; border-radius: 16px;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.06);
  font-size: 14px; line-height: 1.5; word-break: break-word; white-space: pre-wrap;
}
.msg.me .bubble { background: linear-gradient(135deg, #14a871, #0d8a5f); color: #fff; border-bottom-right-radius: 5px; }
.msg:not(.me) .bubble { border-bottom-left-radius: 5px; }
.bubble.sys { background: rgba(0,0,0,.05); box-shadow: none; color: var(--light); font-size: 12px; text-align: center; max-width: 100%; border-radius: 12px; }
.chat-input { display: flex; gap: 8px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); position: sticky; bottom: 0; background: #eef1f4; }
.chat-input input { flex: 1; padding: 12px 16px; border-radius: 22px; border: 1.5px solid var(--line); background: #fff; }
.chat-input input:focus { outline: none; border-color: var(--brand-2); }
.chat-input button { width: 76px; border-radius: 22px; background: linear-gradient(135deg, #14a871, #0d8a5f); color: #fff; font-weight: 700; box-shadow: 0 4px 12px rgba(15,138,95,.28); }

/* ---------- 我的书（操作按钮横排，不再竖着堆） ---------- */
.mine-item { margin-bottom: 14px; }
.mine-item .book-card { margin-bottom: 8px; }
.mine-btns { display: flex; gap: 8px; }
.mine-btns .btn { flex: 1; padding: 9px 0; font-size: 13px; }

/* ---------- 聊天页：整页 flex，输入框固定在首屏底部 ---------- */
#view.chatpage {
  flex: 0 0 auto; /* 覆盖 #view 的 flex:1 —— 否则被拉伸、height 失效、输入框溢出到 TabBar 后面 */
  display: flex; flex-direction: column;
  /* 减去顶栏(~90) + 悬浮底部导航(~80)：输入框始终在首屏底部、不被 TabBar 挡住 */
  height: calc(100vh - 250px);
  height: calc(100dvh - 250px);
  padding-bottom: 0 !important;
}
.chat-meta {
  flex-shrink: 0; display: flex; gap: 10px; align-items: center;
  background: #fff; border-radius: 14px; padding: 10px 12px; margin-bottom: 8px;
  box-shadow: 0 4px 18px rgba(30,50,42,.07);
}
.back-btn {
  width: 34px; height: 34px; border-radius: 17px; flex-shrink: 0;
  background: #eef0f3; color: var(--ink); font-size: 22px; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding-bottom: 3px;
}
#view#view.chatpage .chat-wrap { flex: 1; height: auto; min-height: 0; padding-bottom: 0; }

/* ---------- 会话列表 ---------- */
.chat-row {
  display: flex; gap: 11px; background: #fff; border-radius: 18px; padding: 13px;
  margin-bottom: 11px; box-shadow: 0 4px 18px rgba(30,50,42,.07); cursor: pointer;
  align-items: center; transition: transform .12s;
}
.chat-row:active { transform: scale(.985); }
.chat-row .cover { width: 48px; height: 62px; font-size: 22px; }
.cr-body { flex: 1; min-width: 0; }
.cr-name { font-weight: 800; font-size: 14.5px; }
.cr-last { color: var(--light); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 上传封面框 ---------- */
.up-box {
  width: 100px; height: 126px; border-radius: 14px; border: 1.5px dashed #c6ced4;
  background: #f6f8f9; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--light); font-size: 12px; overflow: hidden; flex-shrink: 0; text-align: center;
}
.up-box img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 110px; z-index: 99; max-width: 80%;
  background: rgba(28, 34, 32, .92); color: #fff; border-radius: 14px;
  padding: 12px 18px; font-size: 13.5px; text-align: center; line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
}
.empty { text-align: center; color: var(--light); padding: 70px 20px; }
.empty .big { font-size: 48px; margin-bottom: 12px; }
.linkish { color: var(--brand); font-weight: 700; cursor: pointer; }
.center { text-align: center; }

/* ---------- 悬浮底部导航 ---------- */
#tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(492px, calc(100% - 24px));
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(14px);
  border-radius: 21px;
  box-shadow: 0 8px 30px rgba(20, 40, 32, .16);
  display: flex; padding: 7px 4px;
  z-index: 50;
}
#tabbar a {
  position: relative; flex: 1; text-align: center; text-decoration: none;
  color: #9aa3a8; font-size: 10.5px; padding: 5px 0 3px;
  border-radius: 15px; transition: color .15s, background .15s;
}
#tabbar a svg { width: 22px; height: 22px; display: block; margin: 0 auto 2px; }
#tabbar a.on { color: #fff; background: linear-gradient(135deg, #14a871, #0d8a5f); box-shadow: 0 4px 12px rgba(15,138,95,.35); }
#tabbar a.on span { font-weight: 700; }
#view { padding-bottom: 108px; }
#view.flush { padding-bottom: 100px; }

/* ---------- 图片灯箱（摆放示例等） ---------- */
.img-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10, 16, 14, .88);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; backdrop-filter: blur(4px);
}
.img-box { max-width: 100%; max-height: 100%; text-align: center; }
.img-box img {
  max-width: 100%; max-height: calc(100vh - 140px);
  border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
