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

/* 关键：hidden 属性必须能压过 .modal-mask 的 display:flex，否则弹窗会一直挡着页面 */
[hidden] { display: none !important; }

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-2: #444444;
  --muted: #8c8c8c;
  --muted-2: #aaaaaa;
  --line: #edeef0;
  --primary: #ff6a00;
  --primary-soft: #fff4e5;
  --price: #ff5000;
  --ok: #0fa968;
  --danger: #f04438;
}

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

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 72px;
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }
img { display: block; }

/* 顶部 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-title { font-size: 17px; font-weight: 700; flex: 1; }
.topbar-back {
  width: 28px; height: 28px; border: none; background: none;
  font-size: 20px; color: var(--text); cursor: pointer; padding: 0;
}

/* 搜索 */
.search { padding: 10px 14px 6px; }
.search input {
  width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 19px;
  padding: 0 16px; font-size: 14px; background: #fff; color: var(--text); outline: none;
}
.search input::placeholder { color: #b8bcc4; }

/* 分段 */
.seg { display: flex; margin: 8px 14px; background: #eef0f3; border-radius: 10px; padding: 3px; }
.seg-item {
  flex: 1; text-align: center; padding: 7px 0; font-size: 14px; color: var(--muted);
  border-radius: 8px; cursor: pointer;
}
.seg-item.on { background: #fff; color: var(--primary); font-weight: 600; }

/* 分类 */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 14px 10px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 14px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line); background: #fff; color: var(--text-2); cursor: pointer;
}
.chip.on { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* 排序条 */
.bar { display: flex; justify-content: space-between; align-items: center; padding: 0 14px 8px; }
.bar .count { font-size: 12px; color: var(--muted-2); }
.bar .sort { font-size: 13px; color: var(--text-2); cursor: pointer; }

/* 商品卡片 */
.grid { display: flex; gap: 10px; padding: 0 14px; align-items: flex-start; }
.col { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card); border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04); cursor: pointer;
}
.cover { height: 150px; background: linear-gradient(135deg, #fff4e5, #fff8f0); position: relative; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-ph {
  height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 40px; color: #ffb27a;
}
.tag {
  position: absolute; left: 8px; top: 8px; font-size: 11px; color: #fff;
  background: rgba(0,0,0,.45); padding: 2px 7px; border-radius: 4px;
}
.tag-corp { left: auto; right: 8px; background: rgba(255,106,0,.85); }
.img-count {
  position: absolute; right: 8px; bottom: 8px; font-size: 11px; color: #fff;
  background: rgba(0,0,0,.45); padding: 2px 7px; border-radius: 4px;
}
.card-body { padding: 8px 10px 10px; }
.card-title {
  font-size: 13px; line-height: 1.45; height: 38px; overflow: hidden; color: var(--text);
}
.card-price { font-size: 16px; font-weight: 700; color: var(--price); margin-top: 6px; }
.card-meta { display: flex; justify-content: space-between; margin-top: 4px; font-size: 11px; color: var(--muted-2); }

/* 通用块 */
.section { padding: 12px 14px; }
.panel { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row-label { color: var(--text-2); font-size: 14px; }
.row-value { color: var(--muted); font-size: 13px; }

/* 详情 */
.gallery { width: 100%; height: 300px; background: #fff4e5; position: relative; overflow: hidden; }
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.gallery-ph {
  height: 100%; display: flex; align-items: center; justify-content: center; font-size: 72px; color: #ffb27a;
}
.gallery-count {
  position: absolute; right: 12px; bottom: 12px; background: rgba(0,0,0,.5); color: #fff;
  font-size: 12px; padding: 2px 9px; border-radius: 999px;
}
.price-line { padding: 14px; background: #fff; }
.price-big { font-size: 28px; font-weight: 700; color: var(--price); }
.item-title { font-size: 17px; line-height: 1.5; margin-top: 8px; }
.item-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.item-tag { font-size: 11px; color: var(--muted); background: #f7f8fa; border: 1px solid var(--line); padding: 2px 8px; border-radius: 4px; }
.desc { font-size: 14px; color: var(--text-2); line-height: 1.8; white-space: pre-wrap; }
.seller { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 16px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.seller-name { font-size: 14px; }
.seller-sub { font-size: 12px; color: var(--muted-2); }

/* 底部操作栏 */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 480px; margin: 0 auto; background: #fff; border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; align-items: center;
}
.actionbar .hint { flex: 1; font-size: 12px; color: var(--muted-2); }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  border-radius: 10px; padding: 10px 16px; font-size: 14px; cursor: pointer;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-block { width: 100%; display: block; }
.btn-ghost { background: #fff; }
.btn-danger { color: var(--danger); border-color: #f5d6d2; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; }

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; max-width: 480px; margin: 0 auto;
  background: #fff; border-top: 1px solid var(--line); display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-item {
  flex: 1; text-align: center; padding: 8px 0 10px; font-size: 12px; color: var(--muted); cursor: pointer;
}
.tabbar-item.on { color: var(--primary); font-weight: 600; }
.tabbar-item .icon { font-size: 18px; display: block; line-height: 1.2; }

/* 悬浮发布 */
.fab {
  position: fixed; right: calc(50% - 240px + 16px); bottom: 84px; z-index: 28;
  width: 52px; height: 52px; border-radius: 50%; border: none; background: var(--primary); color: #fff;
  font-size: 26px; line-height: 52px; text-align: center; box-shadow: 0 6px 16px rgba(255,106,0,.35); cursor: pointer;
}
@media (max-width: 480px) { .fab { right: 16px; } }

/* 列表 */
.list-item { display: flex; gap: 12px; padding: 12px 14px; background: #fff; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: none; }
.thumb { width: 64px; height: 64px; border-radius: 8px; background: #fff4e5; flex: 0 0 auto; overflow: hidden; display: flex; align-items: center; justify-content: center; color: #ffb27a; font-size: 22px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { font-size: 12px; color: var(--muted-2); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-price { font-size: 15px; color: var(--price); font-weight: 600; }
.badge {
  display: inline-block; min-width: 18px; height: 18px; line-height: 18px; text-align: center;
  background: var(--danger); color: #fff; font-size: 11px; border-radius: 999px; padding: 0 5px;
}

/* 聊天 */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 56px); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px 14px; }
.msg { display: flex; margin-bottom: 12px; }
.msg.mine { justify-content: flex-end; }
.bubble {
  max-width: 72%; padding: 9px 12px; border-radius: 12px; background: #fff; font-size: 14px;
  border: 1px solid var(--line); word-break: break-word;
}
.msg.mine .bubble { background: var(--primary); color: #fff; border-color: var(--primary); }
.chat-input {
  display: flex; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line);
}
.chat-input input { flex: 1; height: 38px; border: 1px solid var(--line); border-radius: 19px; padding: 0 14px; font-size: 14px; outline: none; }

/* 表单 */
.field { padding: 12px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: none; }
.field-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  font-size: 14px; outline: none; background: #fff; color: var(--text); font-family: inherit;
}
.field textarea { min-height: 90px; resize: vertical; }
.img-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.img-cell { position: relative; padding-top: 100%; border-radius: 8px; overflow: hidden; background: #f7f8fa; border: 1px dashed #d9dde3; }
.img-cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.img-add { display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 26px; cursor: pointer; }
.img-del { position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 14px; line-height: 22px; text-align: center; cursor: pointer; }
.hint-text { font-size: 12px; color: var(--muted-2); margin-top: 8px; }

/* 空状态 */
.empty { padding: 60px 20px; text-align: center; color: var(--muted-2); font-size: 14px; }
.loading { padding: 40px; text-align: center; color: var(--muted-2); font-size: 13px; }

/* toast */
.toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: 80%; text-align: center;
}
.toast.show { opacity: 1; }

/* modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 320px; padding: 18px; }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.modal-body { font-size: 14px; color: var(--text-2); line-height: 1.7; margin-bottom: 16px; white-space: pre-wrap; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 4px; background: #f2f3f5; color: var(--muted); }
.pill-ok { background: #e8f7f0; color: var(--ok); }
.pill-warn { background: #fff4e5; color: var(--primary); }
