/* 宸寶貝 — 航空郵件包裹風 */
:root {
  --paper: #F3F5FB;
  --card: #FFFFFF;
  --ink: #1F2347;
  --ink-soft: #565B80;
  --muted: #8A8FB0;
  --line: #DFE3F1;
  --rose: #E6457A;
  --rose-soft: #FDE8EF;
  --blue: #3C63D9;
  --blue-soft: #E7ECFC;
  --ok: #1E8E6A;
  --warn: #B26A00;
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --num: "Bricolage Grotesque", "Noto Sans TC", system-ui, sans-serif;
  --body: "Noto Sans TC", system-ui, -apple-system, "PingFang TC", sans-serif;
  --airmail: repeating-linear-gradient(-45deg, var(--rose) 0 10px, #fff 10px 16px, var(--blue) 16px 26px, #fff 26px 32px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.6 var(--body); padding-bottom: 76px;
}
img { max-width: 100%; display: block; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.hidden { display: none !important; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20; background: rgba(243, 245, 251, .92);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 16px; height: 58px; }
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand b { font-size: 22px; font-weight: 900; letter-spacing: .04em; }
.brand span { font-size: 12px; color: var(--muted); }
.topnav { display: none; gap: 4px; }
.topnav a, .tabbar a { text-decoration: none; color: var(--ink-soft); }
.topnav a { padding: 6px 12px; border-radius: 999px; font-size: 14px; }
.topnav a.on { background: var(--ink); color: #fff; }
.cart-btn {
  position: relative; border: 0; background: var(--card); border-radius: 999px; padding: 7px 14px;
  box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; font-size: 14px;
}
.cart-btn .n {
  font-family: var(--num); font-weight: 700; background: var(--rose); color: #fff; border-radius: 999px;
  padding: 0 7px; margin-left: 4px; font-size: 13px;
}

/* bottom tab bar (mobile) */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--card);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a { display: flex; flex-direction: column; align-items: center; font-size: 11px; gap: 2px; padding: 2px 0; }
.tabbar a i { font-style: normal; font-size: 19px; line-height: 1.2; filter: grayscale(1); opacity: .55; }
.tabbar a.on { color: var(--ink); font-weight: 700; }
.tabbar a.on i { filter: none; opacity: 1; }

@media (min-width: 820px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .topnav { display: flex; }
}

/* ---------- banners ---------- */
.notice {
  margin: 12px 0 0; padding: 10px 14px; border-radius: var(--radius); font-size: 14px;
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
}
.notice.login { background: var(--blue-soft); color: var(--ink); }
.notice.maint { background: #FFF4DE; color: var(--warn); }

/* ---------- buttons & form ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; cursor: pointer;
  border-radius: 999px; padding: 10px 18px; font-weight: 700; text-decoration: none; font-size: 15px;
  background: var(--ink); color: #fff;
}
.btn.rose { background: var(--rose); }
.btn.line { background: #06C755; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
label.f { display: block; margin: 14px 0 0; font-size: 14px; font-weight: 700; }
label.f small { font-weight: 400; color: var(--muted); }
.in {
  width: 100%; margin-top: 6px; padding: 11px 13px; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: #fff; font-size: 16px;
}
.in:focus { border-color: var(--blue); outline: none; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.warnbox { font-size: 13px; background: var(--rose-soft); color: #8E1F45; padding: 10px 12px; border-radius: var(--radius-sm); margin: 8px 0 0; }
.err { color: var(--rose); font-size: 14px; min-height: 1em; margin: 8px 0 0; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 0; font-size: 14px; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--rose); flex: none; }

/* ---------- sections ---------- */
h1, h2, h3 { margin: 0; line-height: 1.3; }
.page-h { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 0 12px; gap: 12px; }
.page-h h1 { font-size: 24px; font-weight: 900; }
.page-h p { margin: 0; color: var(--muted); font-size: 14px; }
.sec { margin: 28px 0 0; }
.sec-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sec-h h2 { font-size: 18px; font-weight: 900; }
.panel { background: var(--card); border-radius: var(--radius-lg); padding: 18px; border: 1px solid var(--line); }

/* ---------- hero: 本期連線（航空郵件） ---------- */
.trip {
  margin-top: 16px; border-radius: var(--radius-lg); padding: 8px; background: var(--airmail);
}
.trip-in { background: var(--card); border-radius: 12px; padding: 20px 18px; display: grid; gap: 14px; }
.trip-in .stamp {
  justify-self: start; font-size: 12px; font-weight: 700; color: var(--rose); border: 1.5px dashed var(--rose);
  padding: 2px 10px; border-radius: 6px; transform: rotate(-2deg);
}
.trip-in h1 { font-size: clamp(26px, 6vw, 38px); font-weight: 900; letter-spacing: .02em; }
.trip-in .meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-soft); font-size: 14px; }
.trip-in .acts { display: flex; flex-wrap: wrap; gap: 8px; }

.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
@media (min-width: 820px) { .quick { grid-template-columns: repeat(4, 1fr); } }
.quick a {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-decoration: none;
  color: var(--ink); display: grid; gap: 2px;
}
.quick a b { font-size: 16px; }
.quick a span { font-size: 13px; color: var(--muted); }
.custom-link {
  display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding: 12px 14px;
  border-radius: var(--radius); background: var(--rose-soft); color: #8E1F45; text-decoration: none; font-size: 14px; font-weight: 700;
}

/* tabs / chips */
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 14px; color: var(--ink-soft); }
.seg button.on { background: var(--ink); color: #fff; font-weight: 700; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 13px;
  font-size: 14px; cursor: pointer; color: var(--ink-soft);
}
.chip.on { border-color: var(--ink); color: var(--ink); font-weight: 700; }
.chip small { color: var(--muted); font-family: var(--num); margin-left: 3px; }

/* ---------- product cards ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: 44%; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
@media (min-width: 820px) { .rail { grid-auto-columns: 22%; } }
.rail > * { scroll-snap-align: start; }
.pc { background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); cursor: pointer; text-align: left; padding: 0; position: relative; }
.pc .ph { aspect-ratio: 1; background: var(--blue-soft) center/cover no-repeat; position: relative; }
.pc .ph .rank {
  position: absolute; left: 8px; top: 8px; font-family: var(--num); font-weight: 800; font-size: 20px; color: #fff;
  text-shadow: 0 1px 4px rgba(31, 35, 71, .5);
}
.pc .badge { position: absolute; right: 8px; top: 8px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--rose); color: #fff; }
.pc .badge.out { background: var(--ink); }
.pc .badge.soon { background: var(--blue); }
.pc .tx { padding: 10px 11px 12px; }
.pc .nm { font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; }
.price { font-family: var(--num); font-weight: 700; color: var(--rose); font-size: 17px; }
.price small { font-size: 12px; margin-right: 1px; }
.price s { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- sheet (modal / drawer) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(31, 35, 71, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 0 0 calc(18px + env(safe-area-inset-bottom)); animation: up .22s ease-out;
}
@media (min-width: 820px) { .scrim { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet-h { position: sticky; top: 0; background: var(--card); display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); z-index: 2; }
.sheet-h h3 { font-size: 17px; }
.sheet-b { padding: 16px 18px; }
.x { border: 0; background: var(--paper); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.sheet.airmail { border-top: 8px solid transparent; border-image: var(--airmail) 8; }

.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; background: var(--paper); }
.gallery img { flex: none; width: 100%; aspect-ratio: 1; object-fit: contain; scroll-snap-align: center; background: #fff; }
.crop { width: 100%; aspect-ratio: 1; background-repeat: no-repeat; background-color: #fff; }
.vlist { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.vbtn { border: 1.5px solid var(--line); background: #fff; border-radius: var(--radius-sm); padding: 7px 12px; cursor: pointer; font-size: 14px; text-align: left; }
.vbtn.on { border-color: var(--rose); background: var(--rose-soft); }
.vbtn:disabled { opacity: .4; text-decoration: line-through; cursor: not-allowed; }
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; }
.qty button { border: 0; background: transparent; width: 38px; height: 38px; font-size: 18px; cursor: pointer; }
.qty span { min-width: 34px; text-align: center; font-family: var(--num); font-weight: 700; }
.desc { white-space: pre-wrap; color: var(--ink-soft); font-size: 14px; }

/* cart */
.ci { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.ci .th { width: 64px; height: 64px; border-radius: var(--radius-sm); background: var(--blue-soft) center/cover; }
.ci .nm { font-size: 14px; }
.ci .sub { font-size: 13px; color: var(--muted); }
.ci .rm { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0; }
.total { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 0 4px; font-weight: 700; }
.total .price { font-size: 24px; }

/* orders */
.due { display: grid; gap: 10px; }
.due-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.due-row.hot { border: 2px solid var(--rose); }
.due-row .lbl { font-size: 14px; color: var(--ink-soft); }
.due-row .price { font-size: 22px; }
.oc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.oc-h { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.oc-h b { font-family: var(--num); }
.oc-h .camp { font-size: 13px; color: var(--muted); }
.st { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); white-space: nowrap; }
.st.pending, .st.awaiting_balance, .st.approved, .st.reported { background: var(--rose-soft); color: #A3214F; }
.st.paid, .st.completed, .st.deposit_paid { background: #E3F5EE; color: var(--ok); }
.st.cod { background: #FFF4DE; color: var(--warn); }
.st.cancelled, .st.rejected, .st.expired { background: #EEE; color: #777; }
.oi { display: flex; justify-content: space-between; font-size: 14px; padding: 6px 0; border-bottom: 1px dashed var(--line); gap: 8px; }
.oi:last-child { border-bottom: 0; }
.oc-f { display: flex; justify-content: flex-end; gap: 16px; font-size: 13px; color: var(--ink-soft); margin-top: 8px; flex-wrap: wrap; }
.oc-f b { color: var(--ink); font-family: var(--num); }
.kv { display: grid; grid-template-columns: 7em 1fr; gap: 8px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.va { font-family: var(--num); font-size: 22px; font-weight: 700; letter-spacing: .06em; }

/* bind steps */
.steps { display: flex; gap: 6px; margin: 4px 0 16px; }
.steps div { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.steps div.on { background: var(--rose); }

/* footer */
footer { margin: 48px 0 0; padding: 26px 0 30px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
footer .links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 10px; }
footer a { color: var(--ink-soft); }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 60; max-width: 90vw;
}
.spin { text-align: center; color: var(--muted); padding: 30px; }
.crop.noimg { aspect-ratio: 5/2; background: var(--blue-soft); display: grid; place-items: center; color: var(--muted); font-size: 14px; border-radius: var(--radius); }
.gallery + .dots { display: none; }

/* ---------- v2：搜尋、試算、手機底部操作列 ---------- */
.search { display: flex; gap: 8px; margin-top: 14px; }
.search .in { margin: 0; }
.toolbar { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 10px; position: sticky; top: 58px; z-index: 5; background: var(--paper); padding: 6px 0; }
.toolbar .in { margin: 0; }
.toolbar select.in { width: auto; padding-right: 8px; }
.due-banner { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--ink); color: #fff; text-decoration: none; font-size: 15px; }
.due-banner b { color: #FFC4D6; font-family: var(--num); }
@media (max-width: 819px) { .quick { display: none; } }

.vbtn .vp { display: block; font-family: var(--num); color: var(--rose); font-weight: 700; }
.gal-hint { text-align: center; margin: 6px 0 0; }
.gallery a { flex: none; width: 100%; scroll-snap-align: center; }
.gallery a img { width: 100%; }

.sheet { padding-bottom: 0; }
.sheet-b { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.sheet-foot {
  position: sticky; bottom: 0; margin: 16px -18px calc(-18px - env(safe-area-inset-bottom));
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center; z-index: 3;
}
.sheet-foot .btn { flex: 1; min-height: 46px; }
.sheet-foot .btn.rose { flex: 2; }
.sheet-foot #pprice2 { flex: 1; }

.added { display: flex; gap: 12px; align-items: center; }
.added .th { width: 64px; height: 64px; border-radius: var(--radius-sm); background: var(--blue-soft) center/cover; flex: none; }
.two-btn { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 18px; }
.two-btn .btn { min-height: 46px; }

.cprev { margin: 10px 0 4px; border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 4px 12px; }
.cp-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.cp-row:last-child { border-bottom: 0; }
.cp-sum { font-weight: 700; align-items: baseline; }
.cp-sum .price { font-size: 20px; }

/* 手機上點擊範圍至少 44px */
@media (max-width: 819px) {
  .qty button { width: 44px; height: 44px; }
  .ci .rm { padding: 8px 0; }
  .chip { padding: 7px 14px; }
}

@media (max-width: 560px) {
  .ci { grid-template-columns: 56px 1fr; grid-template-rows: auto auto; row-gap: 6px; }
  .ci .th { width: 56px; height: 56px; grid-row: span 2; }
  .ci > div:last-child { display: flex; align-items: center; justify-content: space-between; text-align: left !important; }
  .ci > div:last-child .qty { transform: none !important; }
}
.search .btn { flex: none; white-space: nowrap; padding: 0 18px; }
.search + #dueBanner:empty + .trip { margin-top: 12px; }
