/* 二手市集 — 京東風格（白底 + 京東紅 #e1251b） */
:root {
  --bg: #f4f4f4;
  --card: #ffffff;
  --border: #e8e8e8;
  --fg: #333333;
  --fg-dim: #767676;
  --red: #e1251b;
  --red-hover: #f10214;
  --red-bg: #fef0ef;
  --success: #52a352;
  --warn: #f19c2a;
  --danger: #e1251b;
  --shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); }
body { font-family: -apple-system, 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', 'Helvetica Neue', Arial, sans-serif; color: var(--fg); font-size: 14px; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--fg); background: #fff; border: 1px solid #ccc; border-radius: 2px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); }
textarea { min-height: 110px; resize: vertical; }
.mono { font-variant-numeric: tabular-nums; }
.dim { color: var(--fg-dim); }
.hint { font-size: 12px; color: var(--fg-dim); font-weight: 400; }

/* ---------- 頂欄 ---------- */
.topbar { display: flex; align-items: center; gap: 24px; background: #fff; border-bottom: 1px solid var(--border); padding: 0 32px; height: 60px; position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 22px; font-weight: 800; color: var(--red); letter-spacing: 1px; white-space: nowrap; }
.brand i { font-size: 20px; }
.searchbox { flex: 1; max-width: 560px; display: flex; align-items: center; border: 2px solid var(--red); border-radius: 2px; height: 38px; background: #fff; }
.searchbox i { padding: 0 12px; color: var(--red); }
.searchbox input { border: none; height: 100%; }
.searchbox input:focus { border: none; }
.searchbox::after { content: '搜尋'; background: var(--red); color: #fff; font-size: 15px; font-weight: 700; padding: 0 22px; height: 100%; display: flex; align-items: center; cursor: pointer; white-space: nowrap; flex: none; }
.topnav { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.inbox-link { position: relative; color: #666; padding: 8px; font-size: 18px; }
.inbox-link:hover { color: var(--red); }
.unread-badge { position: absolute; top: 0; right: -4px; background: var(--red); color: #fff; font-size: 10px; min-width: 16px; height: 16px; line-height: 16px; text-align: center; border-radius: 8px; padding: 0 4px; font-weight: 700; }

/* ---------- 按鈕 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #ccc; background: #fff; color: var(--fg); padding: 8px 16px; border-radius: 2px; font-size: 14px; white-space: nowrap; transition: color .12s, border-color .12s, background .12s; }
.btn:hover { color: var(--red); border-color: var(--red); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--red-hover); border-color: var(--red-hover); color: #fff; }
.btn-danger { border-color: #ddd; color: var(--danger); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn-offer { color: var(--red); border-color: var(--red); font-weight: 700; }
.btn-offer:hover { background: var(--red-bg); }

/* ---------- Google 地圖嵌入 ---------- */
.map-frame { margin-top: 16px; }
.map-frame iframe { width: 100%; border: 1px solid var(--border); border-radius: 4px; display: block; background: #eee; }
.btn-ghost { border-color: transparent; color: var(--fg-dim); }
.btn-ghost:hover { color: var(--red); border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

/* ---------- 版面 ---------- */
.layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; max-width: 1500px; margin: 16px auto; padding: 0 16px; align-items: start; }
.sidebar { background: var(--card); border: 1px solid var(--border); border-radius: 2px; padding: 12px 0; position: sticky; top: 76px; }
.side-title { font-size: 12px; color: #767676; padding: 8px 20px 4px; }
.sidebar nav { display: flex; flex-direction: column; }
.sidebar nav a { display: flex; align-items: center; gap: 8px; padding: 8px 20px; color: #555; font-size: 14px; }
.sidebar nav a i { width: 18px; text-align: center; color: #999; }
.sidebar nav a:hover { color: var(--red); }
.sidebar nav a:hover i { color: var(--red); }
.sidebar nav a.active { color: var(--red); font-weight: 700; background: var(--red-bg); }
.sidebar nav a.active i { color: var(--red); }
.side-note { margin: 12px 16px 4px; padding: 10px 12px; background: var(--red-bg); border-radius: 2px; font-size: 12px; color: #a04540; line-height: 1.7; }
.side-note i { color: var(--red); }
.main { min-width: 0; padding-bottom: 48px; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 2px; padding: 14px 20px; }
.page-title { font-size: 18px; font-weight: 800; }
.page-sub { color: var(--fg-dim); font-size: 13px; }

/* ---------- 熱門搜尋 / 熱門商品 ---------- */
.hot-strip { display: flex; gap: 14px; overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 2px; padding: 14px 16px; margin-bottom: 14px; }
.hot-strip .hot-label { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--red); font-weight: 800; font-size: 13px; gap: 2px; padding-right: 10px; border-right: 1px solid var(--border); }
.hot-card { flex: 0 0 128px; width: 128px; }
.hot-card img, .hot-card .ph { width: 128px; height: 96px; object-fit: cover; border-radius: 2px; background: #f5f5f5; }
.hot-card .t { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; color: #333; }
.hot-card .v { font-size: 11px; color: var(--fg-dim); }
.kw-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 2px; padding: 10px 16px; margin-bottom: 14px; font-size: 13px; }
.kw-strip .lbl { color: var(--red); font-weight: 700; }
.kw-chip { border: 1px solid var(--border); border-radius: 12px; padding: 2px 12px; color: #666; cursor: pointer; background: #fafafa; }
.kw-chip:hover { color: var(--red); border-color: var(--red); background: #fff; }

/* ---------- 卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 2px; overflow: hidden; display: block; transition: box-shadow .15s, transform .15s; position: relative; }
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); transform: translateY(-2px); }
.card-img-wrap { position: relative; aspect-ratio: 1 / 1; background: #fafafa; }
.card-img { width: 100%; height: 100%; object-fit: cover; }
.card-img.placeholder { display: flex; align-items: center; justify-content: center; color: #ddd; font-size: 34px; }
.card-body { padding: 10px 12px 12px; }
.card-title { font-size: 14px; color: #333; line-height: 1.45; height: 2.9em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-price { display: block; margin-top: 8px; color: var(--red); font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.card-price .pr { font-size: 13px; margin-right: 1px; }
.card-price.free { font-size: 15px; }
.card-meta { margin-top: 6px; font-size: 12px; color: #767676; display: flex; align-items: center; gap: 6px; }
.tag { background: #f4f4f4; color: #666; border-radius: 2px; padding: 1px 6px; font-size: 11px; }
.badge-sold { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 2px; }
.fav-btn { position: absolute; top: 8px; right: 8px; z-index: 3; border: none; background: rgba(255,255,255,.92); color: #bbb; width: 30px; height: 30px; border-radius: 50%; font-size: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.fav-btn:hover { color: var(--red); }
.fav-btn.on { color: var(--red); }

/* ---------- 詳情 ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.detail > div:first-child { background: var(--card); border: 1px solid var(--border); border-radius: 2px; padding: 20px; }
.gallery-main { width: 100%; max-height: 520px; object-fit: contain; background: #fafafa; border: 1px solid var(--border); border-radius: 2px; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gallery-thumbs img { width: 64px; height: 64px; object-fit: cover; border: 2px solid transparent; border-radius: 2px; cursor: pointer; }
.gallery-thumbs img.active { border-color: var(--red); }
.desc { margin-top: 18px; white-space: pre-wrap; color: #444; font-size: 15px; }
.seller-box { background: var(--card); border: 1px solid var(--border); border-radius: 2px; padding: 24px; position: sticky; top: 76px; }
.seller-box h1 { font-size: 20px; line-height: 1.45; }
.detail-price { color: var(--red); font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 10px 0 16px; background: #fff9f8; padding: 10px 14px; border-radius: 2px; }
.detail-price .note { font-size: 13px; color: #c66; margin-left: 8px; font-weight: 400; }
.kv { display: grid; grid-template-columns: 76px 1fr; gap: 8px 12px; font-size: 14px; margin-bottom: 16px; }
.kv dt { color: #999; }
.kv dd { margin: 0; }
.contact-box { background: var(--red-bg); border: 1px solid #f8cfc9; border-radius: 2px; padding: 10px 14px; color: var(--red); font-weight: 700; margin: 12px 0 6px; word-break: break-all; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.seller-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); margin-top: 8px; }
.nick-avatar { width: 36px; height: 36px; border-radius: 50%; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; flex: 0 0 auto; }
.offers-box { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.offers-box h3 { font-size: 14px; margin-bottom: 8px; }
.offer-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 2px; margin-bottom: 8px; font-size: 13px; }
.offer-row .p { color: var(--red); font-weight: 800; font-variant-numeric: tabular-nums; }
.status-pill { font-size: 11px; padding: 1px 8px; border-radius: 9px; }
.status-pill.pending { background: #fef4e6; color: #c77c1e; }
.status-pill.accepted { background: #e9f6e9; color: var(--success); }
.status-pill.declined { background: #f4f4f4; color: #999; }

/* ---------- 表單 ---------- */
.form { display: flex; flex-direction: column; gap: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 2px; padding: 24px; max-width: 720px; }
.form label { display: block; font-weight: 700; margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.uploader { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb { position: relative; width: 96px; height: 96px; border: 1px solid var(--border); border-radius: 2px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; right: 2px; border: none; background: rgba(0,0,0,.55); color: #fff; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; }
.upload-add { width: 96px; height: 96px; border: 1px dashed #ccc; background: #fafafa; color: #999; border-radius: 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.upload-add:hover { border-color: var(--red); color: var(--red); }

/* ---------- 聊天 ---------- */
.chat-wrap { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
.inbox { background: var(--card); border: 1px solid var(--border); border-radius: 2px; overflow: hidden; }
.inbox-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.inbox-item:hover { background: #fafafa; }
.inbox-item.active { background: var(--red-bg); }
.inbox-item .av { width: 38px; height: 38px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; flex: 0 0 auto; }
.inbox-item .mid { flex: 1; min-width: 0; }
.inbox-item .who { font-weight: 700; display: flex; justify-content: space-between; gap: 6px; }
.inbox-item .who .t { color: #bbb; font-weight: 400; font-size: 12px; white-space: nowrap; }
.inbox-item .last { color: var(--fg-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-item .unread { color: var(--red); font-weight: 800; }
.chat-box { background: var(--card); border: 1px solid var(--border); border-radius: 2px; display: flex; flex-direction: column; height: 560px; }
.chat-head { padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.chat-head img { width: 40px; height: 40px; object-fit: cover; border-radius: 2px; background: #f2f2f2; }
.chat-head a { font-weight: 700; }
.chat-head a:hover { color: var(--red); }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; background: #f7f7f7; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { display: flex; gap: 8px; max-width: 74%; }
.chat-msg.me { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg .av { width: 32px; height: 32px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex: 0 0 auto; }
.chat-bubble { background: #fff; border: 1px solid var(--border); padding: 8px 12px; border-radius: 4px; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.chat-msg.me .chat-bubble { background: #fbe3e1; border-color: #f5c8c4; }
.chat-time { font-size: 11px; color: #bbb; align-self: center; }
.offer-bubble { border: 1px solid #f5c8c4; background: #fff8f7; border-radius: 4px; padding: 10px 12px; }
.offer-bubble .op { color: var(--red); font-weight: 800; font-size: 16px; }
.chat-input-row { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; }
.chat-input-row .btn { flex: 0 0 auto; }

/* ---------- 其他 ---------- */
.pager { display: flex; gap: 6px; justify-content: center; margin: 22px 0; }
.empty { text-align: center; color: var(--fg-dim); padding: 60px 20px; background: var(--card); border: 1px solid var(--border); border-radius: 2px; }
.empty i { font-size: 40px; color: #ddd; display: block; margin-bottom: 12px; }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 10px 20px; border-radius: 2px; z-index: 300; box-shadow: 0 4px 12px rgba(0,0,0,.25); max-width: 80vw; }
.toast.error { background: var(--red); }
table.admin { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 2px; font-size: 13px; }
table.admin th, table.admin td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.admin th { color: #888; font-weight: 400; background: #fafafa; }
.prose { background: var(--card); border: 1px solid var(--border); border-radius: 2px; padding: 28px 32px; max-width: 760px; line-height: 1.9; }
.prose h1 { margin-bottom: 12px; }
.prose h2 { font-size: 16px; margin: 22px 0 8px; }
.prose ul { padding-left: 22px; }
.prose li { margin-bottom: 6px; color: #555; }
.avatar-btn { border: none; background: none; padding: 0; }
.login-menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 46px; background: #fff; border: 1px solid var(--border); border-radius: 2px; box-shadow: var(--shadow); min-width: 200px; padding: 6px 0; z-index: 100; }
.menu-pop a, .menu-pop button { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; padding: 9px 16px; border: none; background: none; color: var(--fg); font-size: 13.5px; }
.menu-pop a:hover, .menu-pop button:hover { background: #fafafa; color: var(--red); }
.menu-pop .who { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.menu-pop .danger { color: var(--danger); }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 4px; padding: 24px; width: min(440px, 92vw); }
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.modal .field { margin-bottom: 14px; }
.modal .field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 13px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.profile-box { background: var(--card); border: 1px solid var(--border); border-radius: 2px; padding: 28px; max-width: 480px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; }
  .side-title, .side-note { display: none; }
  .detail { grid-template-columns: 1fr; }
  .seller-box { position: static; }
  .chat-wrap { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; gap: 10px; }
}

/* --- v3：特價 / 收購 / 上傳進度 / VIP --- */
.orig-price { font-size: 12px; color: var(--fg-dim); text-decoration: line-through; margin-left: 8px; font-weight: 400; }
.badge-deal { position: absolute; top: 8px; left: 8px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 2px; }
.badge-sold + .badge-deal, .badge-deal ~ .badge-wanted { left: auto; }
.badge-wanted { position: absolute; bottom: 8px; left: 8px; background: #2f54eb; color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 2px; }
.grid-deal { margin-bottom: 22px; }
.deal-label { display: flex; gap: 8px; align-items: baseline; color: var(--red); font-weight: 800; font-size: 15px; margin: 4px 0 10px; }
.thumb.uploading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: #fafafa; }
.thumb.uploading .up-pct { font-size: 15px; font-weight: 800; color: var(--red); font-variant-numeric: tabular-nums; }
.thumb.uploading .up-bar { width: 76px; height: 5px; background: #eee; border-radius: 3px; overflow: hidden; }
.thumb.uploading .up-bar i { display: block; height: 100%; width: 0; background: var(--red); transition: width .15s; }
.vip-badge { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; margin-left: 8px; background: linear-gradient(90deg, #b8860b, #e6a817); color: #fff; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: wait; }

/* --- v4：聯繫站長 / Turnstile --- */
.contact-item { background: var(--card, #fff); border: 1px solid var(--border, #e5e5e5); border-radius: 6px; padding: 12px 14px; margin-bottom: 12px; }
.contact-reply { background: #fff7f7; border: 1px solid #f3d4d4; padding: 8px 10px; margin-top: 8px; border-radius: 6px; font-size: 13px; }
.ts-box { display: flex; justify-content: center; margin: 8px 0; min-height: 4px; }

/* --- v4.1：官方產品參考連結 --- */
.ref-link-box { background: var(--card, #fff); border: 1px solid var(--border, #e5e5e5); border-radius: 6px; padding: 10px 12px; margin: 12px 0; font-size: 14px; }
.ref-link-box a { font-weight: 700; text-decoration: none; }
.ref-link-box a:hover { text-decoration: underline; }

/* ---------- 站長後台：關鍵字管理 ---------- */
.term-list { display: flex; flex-wrap: wrap; gap: 8px; }
.term-chip { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 14px; padding: 4px 10px; font-size: 13px; background: var(--card); }
.badge-fav { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,.68); color: #ff7875; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 2px; display: inline-flex; align-items: center; gap: 4px; }
