/* ── 實拍夥伴 設計系統 ─────────────────────────────── */
:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --ink: #27231d;
  --ink-2: #57503f;
  --muted: #948b7b;
  --line: #e7e1d5;
  --brand: #e4571f;
  --brand-deep: #c2440f;
  --brand-soft: #fceee5;
  --ok: #237a4b;
  --ok-soft: #e4f2e9;
  --warn: #9a6b12;
  --warn-soft: #faf0d8;
  --danger: #bb3226;
  --danger-soft: #fbe9e6;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgba(60, 45, 20, 0.06), 0 4px 14px rgba(60, 45, 20, 0.07);
  --shadow-lg: 0 8px 40px rgba(40, 25, 5, 0.18);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}
img { max-width: 100%; }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── 頂欄 ── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(247, 244, 238, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1180px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--brand); display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(228, 87, 31, 0.35);
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 0.02em; }
.brand-slogan { font-size: 11.5px; color: var(--muted); margin-top: -3px; }
.topbar-spacer { flex: 1; }
.me-chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px 5px 6px; box-shadow: var(--shadow); border-color: var(--line);
  max-width: 46vw;
}
.me-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--brand-soft); color: var(--brand-deep);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.me-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-code { font-size: 11px; color: var(--muted); flex: none; }

/* ── 說明帶 ── */
.hero { max-width: 1180px; margin: 0 auto; padding: 18px 16px 4px; }
.hero-title { font-size: 20px; font-weight: 700; margin: 0 0 2px; }
.hero-sub { color: var(--ink-2); font-size: 13.5px; margin: 0 0 12px; }
.steps { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.steps::-webkit-scrollbar { display: none; }
.step {
  flex: 1 0 auto; min-width: 150px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px 13px; display: flex; gap: 10px; align-items: center;
}
/* 要寫 .step .step-n：.step-n 也是 span，只寫 .step-n 會被下面的 .step span（display:block）蓋掉而沒置中 */
.step .step-n {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: var(--brand-soft); color: var(--brand-deep);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  line-height: 1; margin-top: 0;
}
.step b { font-size: 13.5px; display: block; }
.step span { font-size: 11.5px; color: var(--muted); display: block; margin-top: 1px; }

/* 獨立登入頁 */
.login-wrap { max-width: 440px; margin: 0 auto; padding: 24px 16px 60px; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 22px 18px 18px; box-shadow: var(--shadow);
}

/* ── 統計膠囊 ── */
.stats { display: flex; gap: 8px; margin: 12px 0 0; flex-wrap: wrap; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; padding: 4px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
}
.stat-pill b { font-size: 13.5px; }
.stat-pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-avail { background: var(--brand); }
.dot-claim { background: #e0a10c; }
.dot-done { background: var(--ok); }

/* 自己找的商品：步驟編號與連結狀態 */
.stepno {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; margin-right: 6px;
  vertical-align: -3px;
}
.linkmsg { font-size: 12.5px; margin-top: 6px; min-height: 17px; }
.linkmsg.wait { color: var(--muted); }
.linkmsg.ok { color: var(--ok); font-weight: 500; }
.linkmsg.err { color: var(--danger); }
.prod-head.mini { margin-bottom: 13px; }
.prod-head.mini img, .prod-head.mini .ph2 { width: 58px; height: 58px; }
.prod-head.mini .nm { font-size: 12.5px; -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }

/* 自己找的商品入口 */
.own-cta {
  display: flex; align-items: center; gap: 11px; width: 100%; margin-top: 10px;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: var(--r-md); padding: 10px 13px; text-align: left;
}
.own-cta:active { background: var(--brand-soft); }
.own-ico { font-size: 19px; flex: none; }
.own-txt { flex: 1; min-width: 0; }
.own-txt b { display: block; font-size: 13.5px; }
.own-txt span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.own-arrow { color: var(--brand); font-size: 16px; flex: none; }

/* ── 篩選列 ── */
.filterbar {
  position: sticky; top: 55px; z-index: 30;
  background: linear-gradient(var(--bg) 82%, rgba(247, 244, 238, 0));
  padding: 10px 0 12px;
}
.filterbar-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.searchrow { display: flex; gap: 8px; margin-bottom: 9px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 8px 12px;
}
.search input { border: 0; outline: 0; flex: 1; background: none; font-size: 14px; min-width: 0; }
.search svg { flex: none; color: var(--muted); }
.mine-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-md);
  padding: 8px 13px; font-size: 13.5px; color: var(--ink-2); white-space: nowrap;
}
.chips { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border-radius: 999px; padding: 6px 13px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
}
.chip .n { color: var(--muted); font-size: 11.5px; margin-left: 3px; }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 500; }
.chip.active .n { color: rgba(255, 255, 255, 0.65); }

/* ── 商品牆 ── */
.wall { max-width: 1180px; margin: 0 auto; padding: 2px 16px 80px; }
.grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}
@media (max-width: 380px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.card {
  text-align: left; padding: 0; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); overflow: hidden; display: flex; flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
@media (hover: hover) {
  .card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
}
.thumb { position: relative; aspect-ratio: 1; background: #efece5; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 30px; }
.badge {
  position: absolute; left: 7px; bottom: 7px;
  font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 999px;
  backdrop-filter: blur(3px);
}
.badge-claim { background: rgba(255, 248, 225, 0.94); color: #8a5c00; border: 1px solid #e8d9ae; }
/* 已完成：整張變暗 */
.card.done .thumb img { filter: grayscale(1) brightness(0.52); }
.card.done .thumb::after {
  content: ""; position: absolute; inset: 0; background: rgba(30, 25, 15, 0.18);
}
.done-stamp {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 2;
}
.done-stamp span {
  background: rgba(255, 255, 255, 0.93); color: var(--ok);
  font-size: 12.5px; font-weight: 700; padding: 5px 13px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}
.card.done .cinfo { opacity: 0.62; }
.cinfo { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.cname {
  font-size: 12.8px; line-height: 1.4; margin: 0; font-weight: 400; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.8em;
}
.crow { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; margin-top: auto; }
.cprice { color: var(--brand-deep); font-weight: 700; font-size: 14.5px; }
.cprice small { font-size: 11px; font-weight: 400; margin-right: 1px; }
.ccat { font-size: 10.5px; color: var(--muted); white-space: nowrap; }

/* 骨架屏 */
.sk { border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.sk .a { aspect-ratio: 1; background: #ece8df; animation: pulse 1.3s ease-in-out infinite; }
.sk .b { height: 12px; margin: 10px; border-radius: 6px; background: #ece8df; animation: pulse 1.3s ease-in-out infinite; }
.sk .c { height: 12px; margin: 0 10px 12px; width: 55%; border-radius: 6px; background: #ece8df; animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.loadmore { text-align: center; padding: 18px; color: var(--muted); font-size: 13px; }

/* ── Modal / 底部抽屜 ── */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(30, 20, 8, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein 0.18s ease;
}
@keyframes fadein { from { opacity: 0; } }
.sheet {
  background: var(--surface); width: 100%; max-width: 520px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  animation: slideup 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slideup { from { transform: translateY(40px); opacity: 0.6; } }
@media (min-width: 640px) {
  .overlay { align-items: center; padding: 24px; }
  .sheet { border-radius: var(--r-lg); max-height: 88vh; box-shadow: var(--shadow-lg); }
}
.sheet-head {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.sheet-title { font-size: 15.5px; font-weight: 700; flex: 1; margin: 0; }
.x-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--bg);
  color: var(--ink-2); display: grid; place-items: center; font-size: 15px; flex: none;
}
.sheet-body { padding: 14px 16px 26px; }

/* 商品資訊列 */
.prod-head { display: flex; gap: 12px; }
.prod-head img, .prod-head .ph2 {
  width: 86px; height: 86px; border-radius: var(--r-sm); object-fit: cover; flex: none;
  background: #efece5; display: grid; place-items: center; color: var(--muted); font-size: 26px;
  border: 1px solid var(--line);
}
.prod-head .t { flex: 1; min-width: 0; }
.prod-head .nm { font-size: 13.5px; line-height: 1.45; margin: 0 0 4px; }
.prod-head .pr { color: var(--brand-deep); font-weight: 700; font-size: 15px; }
.prod-head .shop { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.linkrow { display: flex; gap: 8px; margin: 12px 0 2px; }
.minilink {
  flex: 1; text-align: center; font-size: 13px; padding: 8px 4px; border-radius: var(--r-sm);
  background: var(--bg); border: 1px solid var(--line); color: var(--ink-2); text-decoration: none;
}

/* 狀態盒 */
.statebox { border-radius: var(--r-md); padding: 11px 13px; font-size: 13px; margin: 12px 0; }
.statebox.ok { background: var(--ok-soft); color: var(--ok); }
.statebox.warn { background: var(--warn-soft); color: var(--warn); }
.statebox.info { background: var(--brand-soft); color: var(--brand-deep); }
.statebox b { font-weight: 700; }

/* 按鈕 */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border-radius: var(--r-md); padding: 13px 16px;
  font-size: 15px; font-weight: 700; border: 0; transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(228, 87, 31, 0.3); }
.btn-primary:not(:disabled):active { background: var(--brand-deep); }
.btn-outline { background: var(--surface); border: 1.5px solid var(--line); color: var(--ink-2); font-weight: 500; }
.btn-ghost { background: none; color: var(--muted); font-weight: 400; font-size: 13px; padding: 8px; }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; border-radius: var(--r-sm); }
.btnrow { display: flex; gap: 9px; margin-top: 10px; }

/* 上傳區 */
.dropzone {
  border: 1.6px dashed #d8cfbe; border-radius: var(--r-md); background: #fcfaf6;
  padding: 22px 14px; text-align: center; color: var(--ink-2); font-size: 13.5px;
  display: block; width: 100%;
}
.dropzone .ico { font-size: 26px; display: block; margin-bottom: 5px; }
.dropzone small { color: var(--muted); display: block; margin-top: 4px; font-size: 11.5px; }
.checks { margin: 12px 0; display: flex; flex-direction: column; gap: 7px; }
.checkrow { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; }
.checkrow .ic { flex: none; width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-top: 1px; }
.checkrow.pass .ic { background: var(--ok-soft); color: var(--ok); }
.checkrow.fail .ic { background: var(--danger-soft); color: var(--danger); }
.checkrow.fail { color: var(--danger); }
.filetag {
  display: flex; align-items: center; gap: 9px; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 12px;
  font-size: 13px; margin-top: 10px;
}
.filetag .nm2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filetag button { border: 0; background: none; color: var(--muted); font-size: 13px; }

/* 表單 */
.field { margin: 13px 0; }
.field label { display: flex; align-items: center; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--ink-2); }
.field label .cnt { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: auto; }
.field input:not([type="checkbox"]):not([type="radio"]), .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: 14px; background: var(--surface); color: var(--ink);
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--brand); outline: none; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.wordwarn { margin-top: 7px; font-size: 12.5px; border-radius: var(--r-sm); padding: 8px 11px; display: none; }
.wordwarn.block { display: block; background: var(--danger-soft); color: var(--danger); }
.wordwarn.warn { display: block; background: var(--warn-soft); color: var(--warn); }

/* 進度條 */
.progress { margin: 14px 0 6px; }
.ptrack { height: 9px; border-radius: 99px; background: var(--line); overflow: hidden; }
.pbar { height: 100%; width: 0%; background: var(--brand); border-radius: 99px; transition: width 0.25s; }
.ptext { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* 完成畫面 */
.success { text-align: center; padding: 26px 10px 6px; }
.success .big { font-size: 52px; }
.success h3 { margin: 10px 0 4px; font-size: 18px; }
.success p { color: var(--ink-2); font-size: 13.5px; margin: 0 0 4px; }

/* 我的紀錄 */
.mywork { display: flex; flex-direction: column; gap: 10px; }
.mycard { border: 1px solid var(--line); border-radius: var(--r-md); padding: 11px 13px; }
.mycard .r1 { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.mycard .pn { font-size: 13.5px; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11px; padding: 2.5px 9px; border-radius: 999px; flex: none; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-todo { background: var(--warn-soft); color: var(--warn); }
.mycard .meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #2c2620; color: #fff; font-size: 13.5px; padding: 11px 18px;
  border-radius: 999px; z-index: 99; box-shadow: var(--shadow-lg);
  max-width: 88vw; text-align: center;
  animation: fadein 0.2s ease;
}
.toast.err { background: var(--danger); }

/* 暱稱門 */
.gate-body { text-align: center; padding: 8px 6px 4px; }
.gate-body .big { font-size: 44px; }
.gate-body h3 { margin: 8px 0 4px; font-size: 18px; }
.gate-body p { color: var(--ink-2); font-size: 13.5px; margin: 0 0 14px; }
.gate-alt { margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.gate-alt input { width: 110px; padding: 6px 10px; border: 1.5px solid var(--line); border-radius: var(--r-sm); margin: 0 6px; font-size: 13px; }

/* 登入/註冊分頁 */
.tabs { display: flex; gap: 6px; background: var(--bg); border-radius: var(--r-md); padding: 4px; margin: 6px 0 4px; }
.tab { flex: 1; border: 0; background: none; padding: 9px 6px; border-radius: 9px; font-size: 13.5px; color: var(--muted); }
.tab.active { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }
.authform .btn { margin-top: 4px; }
.chips-batch { margin-bottom: 7px; }
.chip-batch.active { background: var(--brand); border-color: var(--brand); }

/* ── 管理端 ── */
.admin-wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.admin-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .admin-grid { grid-template-columns: 340px 1fr; align-items: start; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; }
.panel h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 7px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 10px; margin-bottom: 4px; }
.kpi { background: var(--bg); border-radius: var(--r-sm); padding: 10px 12px; }
.kpi b { font-size: 21px; display: block; }
.kpi span { font-size: 11.5px; color: var(--muted); }
.tbl-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 12.8px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11.5px; padding: 7px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl code { font-size: 11px; background: var(--bg); padding: 2px 5px; border-radius: 4px; word-break: break-all; }
.tbl a { color: var(--brand-deep); }
