:root {
  --coral: #ff7a45;
  --coral-dark: #f25c1f;
  --coral-soft: #fff1e9;
  --bg: #fff7f2;
  --card: #ffffff;
  --text: #2b2b2b;
  --muted: #8a8a8a;
  --line: #f0e3da;
  --green: #2bbf7a;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(255, 122, 69, 0.10);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--coral), var(--coral-dark));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(242, 92, 31, 0.25);
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: 1px; }
.topbar .sub { font-size: 11px; opacity: 0.85; margin-top: 2px; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
.topbar .btn { padding: 7px 11px; font-size: 12px; }
.unread-dot {
  display: inline-block; margin-left: 4px; min-width: 15px; padding: 0 4px;
  background: #fff; color: var(--coral-dark); border-radius: 999px;
  font-size: 10px; font-weight: 800; line-height: 15px; text-align: center;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: var(--coral-dark);
  transition: transform 0.05s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--coral); color: #fff; }
.btn-ghost { background: rgba(255,255,255,0.18); color: #fff; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; padding: 13px; font-size: 15px; }

/* ===== 筛选区 ===== */
.filters {
  padding: 12px 14px 4px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  background: var(--bg);
  outline: none;
}
.search-row input:focus { border-color: var(--coral); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--coral); border-color: var(--coral); color: #fff; }

.row2 { display: flex; gap: 8px; margin-top: 8px; }
.row2 select {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--bg);
  font-size: 13px;
  outline: none;
  color: var(--text);
}

/* ===== 物品网格 ===== */
.list { padding: 14px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) { .list { grid-template-columns: repeat(3, 1fr); max-width: 980px; margin: 0 auto; } }
@media (min-width: 1024px) { .list { grid-template-columns: repeat(4, 1fr); } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.08s ease;
}
.card:active { transform: scale(0.98); }
.card .thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #ffe6d6, #ffd2bd);
  display: flex; align-items: center; justify-content: center;
  color: var(--coral-dark);
  font-size: 13px;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .badge-float {
  position: absolute; top: 8px; left: 8px;
}
.card .status-float {
  position: absolute; top: 8px; right: 8px;
}
.card .body { padding: 8px 10px 10px; }
.card .title {
  font-size: 14px; font-weight: 600;
  margin: 0 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 38px;
}
.card .price { color: var(--coral-dark); font-weight: 700; font-size: 15px; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; justify-content: space-between; }

/* ===== 徽章 ===== */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
}
.badge-sell { background: var(--coral); }
.badge-free { background: var(--green); }
.badge-exchange { background: #6c5ce7; }
.badge-wanted { background: #e67e22; }
.badge-muted { background: rgba(0,0,0,0.45); }
.badge-sold { background: #9b9b9b; }

/* ===== 空态 / 加载 ===== */
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.loading { text-align: center; color: var(--muted); padding: 24px; }
.more-wrap { text-align: center; padding: 8px 0 28px; }

/* ===== 详情页 ===== */
.detail { max-width: 720px; margin: 0 auto; padding: 0 0 40px; }
.detail .gallery { display: flex; gap: 8px; overflow-x: auto; padding: 12px; scrollbar-width: none; }
.detail .gallery::-webkit-scrollbar { display: none; }
.detail .gallery img { height: 240px; border-radius: 12px; object-fit: cover; flex: 0 0 auto; background: #eee; }
.detail .gallery .ph { height: 240px; width: 240px; border-radius: 12px; background: linear-gradient(135deg,#ffe6d6,#ffd2bd); display:flex;align-items:center;justify-content:center;color:var(--coral-dark);flex:0 0 auto; }
.detail .info { padding: 4px 16px 16px; }
.detail .info h2 { margin: 6px 0; font-size: 20px; }
.detail .info .price { font-size: 22px; color: var(--coral-dark); font-weight: 800; margin: 6px 0; }
.detail .desc { white-space: pre-wrap; color: #444; background: var(--card); border-radius: 12px; padding: 12px; margin: 12px 0; }
.detail .kv { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.detail .kv .tag { background: var(--coral-soft); color: var(--coral-dark); border-radius: 8px; padding: 4px 10px; font-size: 12px; }
.contact-box { background: var(--coral-soft); border-radius: 12px; padding: 14px; margin: 14px 16px; }
.contact-box .ttl { font-weight: 700; color: var(--coral-dark); margin-bottom: 8px; }
.contact-box .line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.contact-box .copy { color: var(--coral-dark); cursor: pointer; font-weight: 600; }

/* ===== 表单 ===== */
.form-page { max-width: 600px; margin: 0 auto; padding: 14px 16px 60px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.field input[type=text], .field input[type=number], .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  background: var(--card);
  outline: none;
  font-family: inherit;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--coral); }
.field textarea { resize: vertical; min-height: 90px; }
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-group label {
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px;
  cursor: pointer; font-weight: 500; background: var(--card);
}
.radio-group input { display: none; }
.radio-group input:checked + span { color: var(--coral-dark); }
.radio-group label:has(input:checked) { border-color: var(--coral); background: var(--coral-soft); }

.uploader { display: flex; gap: 10px; flex-wrap: wrap; }
.uploader .slot {
  width: 84px; height: 84px; border-radius: 12px; border: 1px dashed var(--coral);
  display: flex; align-items: center; justify-content: center; color: var(--coral);
  font-size: 28px; cursor: pointer; position: relative; overflow: hidden; background: var(--coral-soft);
}
.uploader .slot img { width: 100%; height: 100%; object-fit: cover; }
.uploader .slot .del {
  position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.5); color: #fff;
  width: 18px; height: 18px; border-radius: 50%; font-size: 12px; line-height: 18px; text-align: center;
}

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: rgba(43,43,43,0.92); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 99;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #e74c3c; }
.toast.success { background: var(--green); }

.back-link { display: inline-flex; align-items: center; gap: 4px; padding: 12px 16px; color: var(--coral-dark); font-weight: 600; cursor: pointer; }

/* ===== 骨架屏 ===== */
.card.skel .thumb { background: linear-gradient(100deg, #ffe6d6 30%, #fff4ec 50%, #ffe6d6 70%); background-size: 200% 100%; animation: sk 1.2s infinite; }
.sk-line { height: 12px; border-radius: 6px; margin: 8px 0 0; background: linear-gradient(100deg, #f3e7df 30%, #faf3ee 50%, #f3e7df 70%); background-size: 200% 100%; animation: sk 1.2s infinite; }
.sk-line.w80 { width: 80%; } .sk-line.w40 { width: 40%; } .sk-line.w60 { width: 60%; }
@keyframes sk { to { background-position: -200% 0; } }

/* ===== 详情动作区 ===== */
.action-bar {
  padding: 0 16px 8px;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.btn-faved { background: var(--coral-soft); color: var(--coral-dark); border: 1px solid var(--coral); }
.report-row { text-align: right; padding: 0 16px 24px; }
.report-row a { color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: underline; }
.report-row a:hover { color: #e74c3c; }

/* ===== 消息页 ===== */
.thread-list { max-width: 640px; margin: 0 auto; padding: 10px 0 30px; }
.thread-item {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border-radius: 12px; padding: 12px 14px; margin: 0 12px 10px;
  cursor: pointer; box-shadow: var(--shadow);
}
.thread-item:active { transform: scale(0.99); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--coral), var(--coral-dark));
  color: #fff; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.avatar.big { width: 56px; height: 56px; font-size: 24px; }
.thread-main { flex: 1; min-width: 0; }
.thread-top { display: flex; justify-content: space-between; margin-bottom: 2px; }
.thread-name { font-weight: 700; }
.thread-time { color: var(--muted); font-size: 11px; }
.thread-item-title { font-size: 12px; color: var(--coral-dark); margin-bottom: 2px; }
.thread-last {
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chat-head {
  position: sticky; top: 0; z-index: 5;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 8px 14px; font-size: 13px;
  display: flex; flex-direction: column; gap: 2px;
}
.chat-item-link { color: var(--coral-dark); font-weight: 600; text-decoration: none; }
.chat-with { color: var(--muted); font-size: 12px; }

.msg-list {
  max-width: 640px; margin: 0 auto;
  padding: 14px 12px 90px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 50vh;
}
.msg-row { display: flex; }
.msg-row.mine { justify-content: flex-end; }
.bubble {
  max-width: 76%;
  background: var(--card); border-radius: 14px; padding: 9px 13px;
  font-size: 14px; word-break: break-word; box-shadow: var(--shadow);
}
.msg-row.mine .bubble { background: var(--coral); color: #fff; border-bottom-right-radius: 4px; }
.msg-row:not(.mine) .bubble { border-bottom-left-radius: 4px; }

.chat-input {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 640px; margin: 0 auto;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 8px;
}
.chat-input input {
  flex: 1; border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 14px; font-size: 14px; outline: none; background: var(--bg);
}
.chat-input input:focus { border-color: var(--coral); }

/* ===== 用户主页 ===== */
.user-hero { max-width: 640px; margin: 0 auto; padding: 16px 14px 4px; }
.user-card {
  display: flex; gap: 14px; align-items: center;
  background: var(--card); border-radius: 14px; padding: 16px; box-shadow: var(--shadow);
}
.user-name { font-size: 18px; font-weight: 700; }
.user-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ===== 账号入口（顶栏）===== */
.sub a, .sub #accountSlot a { color: #fff; text-decoration: underline; font-weight: 600; }

/* ===== 管理后台 ===== */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 640px) { .stats-row { grid-template-columns: repeat(6, 1fr); } }
.stat-card { background: var(--card); border-radius: 12px; padding: 12px 8px; text-align: center; box-shadow: var(--shadow); }
.stat-v { font-size: 20px; font-weight: 800; color: var(--coral-dark); }
.stat-k { font-size: 12px; color: var(--muted); }
.report-card {
  display: flex; gap: 10px; align-items: center;
  background: var(--card); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.report-main { flex: 1; min-width: 0; }
.report-title { font-weight: 600; font-size: 14px; }
.report-reason { font-size: 13px; color: #444; margin: 3px 0; word-break: break-word; }
.report-time { font-size: 11px; color: var(--muted); }
