:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c2330;
  --line: #2a3340;
  --text: #e6edf3;
  --muted: #8b96a5;
  --gold: #c8aa6e;
  --gold2: #f0d9a8;
  --blue: #3b82f6;
  --green: #2ea043;
  --red: #da3633;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1a2536 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--gold2); }

/* ---------- header ---------- */
header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: rgba(13,17,23,.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand b { font-size: 18px; letter-spacing: .5px; }
.brand b span { color: var(--gold); }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: 1px; }
.spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user img { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); }
.linkbtn { color: var(--muted); text-decoration: none; font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.linkbtn:hover { color: var(--text); background: var(--bg3); }

/* ---------- layout ---------- */
.wrap { display: grid; grid-template-columns: 1fr 360px; gap: 20px; padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; align-items: start; }
@media (max-width: 960px) { .wrap { grid-template-columns: 1fr; padding: 16px 14px 90px; } .cart { position: static !important; } }
@media (max-width: 600px) {
  header { padding: 12px 14px; gap: 10px; }
  .brand b { font-size: 16px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card .zh { font-size: 13px; }
}

/* 手機浮動購物車掣：快速跳去結算 */
.cartfab { display: none; }
@media (max-width: 960px) {
  .cartfab { display: flex; align-items: center; gap: 8px; position: fixed; right: 16px; bottom: 16px; z-index: 80;
    background: var(--gold); color: #1a1300; border: none; border-radius: 999px; padding: 13px 20px; font-size: 15px; font-weight: 700;
    box-shadow: var(--shadow); cursor: pointer; }
  .cartfab .fc { background: #1a1300; color: var(--gold2); border-radius: 999px; padding: 1px 9px; font-size: 13px; }
  .cartfab.empty { display: none; }
}

/* ---------- search ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search { flex: 1; min-width: 220px; position: relative; }
.search input {
  width: 100%; padding: 13px 14px 13px 40px; font-size: 15px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); outline: none;
}
.search input:focus { border-color: var(--gold); }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
select {
  padding: 13px 12px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); font-size: 14px; outline: none; cursor: pointer;
}
.count { color: var(--muted); font-size: 13px; align-self: center; padding-left: 4px; }

/* ---------- card grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.card {
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: transform .12s, border-color .12s;
}
.card:hover { transform: translateY(-3px); border-color: var(--gold); }
.card .imgbox { aspect-ratio: 3/4; background: var(--bg3); position: relative; }
.card .imgbox.zoomable { cursor: zoom-in; }
.card .imgbox .zoomhint { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); border-radius: 6px; padding: 1px 6px; font-size: 12px; opacity: 0; transition: opacity .12s; z-index: 2; }
.card .imgbox.zoomable:hover .zoomhint { opacity: 1; }
.card .imgbox img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .imgbox .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.card .no { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.7); color: var(--gold2); font-size: 11px; padding: 2px 7px; border-radius: 6px; }
.card .body { padding: 9px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.card .zh { font-size: 14px; font-weight: 600; }
.card .en { font-size: 11px; color: var(--muted); min-height: 13px; }
.card .meta { font-size: 10px; color: var(--gold); margin-top: 2px; }
.card .add {
  margin: 0 10px 10px; padding: 8px; border: 1px solid var(--gold); color: var(--gold2);
  background: transparent; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.card .add:hover { background: var(--gold); color: #1a1300; }
.card.in .add { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------- cart ---------- */
.cart { position: sticky; top: 78px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cart h3 { margin: 0; padding: 16px; border-bottom: 1px solid var(--line); font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.cart h3 .pill { background: var(--gold); color: #1a1300; font-size: 12px; padding: 2px 9px; border-radius: 20px; }
.cart .items { max-height: 50vh; overflow-y: auto; padding: 6px; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; }
.row:hover { background: var(--bg3); }
.row .ri { flex: 1; min-width: 0; }
.row .ri .t { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .ri .s { font-size: 11px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 26px; height: 26px; border: 1px solid var(--line); background: var(--bg3); color: var(--text); border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1; }
.stepper button:hover { border-color: var(--gold); }
.stepper input { width: 40px; text-align: center; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 5px 2px; }
.rm { color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 4px; }
.rm:hover { color: var(--red); }
.cart .foot { padding: 14px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.cart textarea { width: 100%; resize: vertical; min-height: 44px; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 9px; font-family: inherit; font-size: 13px; }
.codebox { display: flex; gap: 8px; align-items: stretch; }
.codebox input { flex: 1; background: var(--bg); border: 1px solid var(--gold); color: var(--gold2); border-radius: 8px; padding: 10px 12px; font-size: 15px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; outline: none; }
.codebox input::placeholder { color: var(--muted); font-weight: 400; letter-spacing: 0; }
.codehelp { display: flex; align-items: center; justify-content: center; width: 38px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 700; }
.codehelp:hover { border-color: var(--gold); color: var(--gold2); }
.codestate { font-size: 12px; min-height: 14px; color: var(--muted); }
.codestate.ok { color: var(--green); }
.codestate.ok b, .codestate.err b { color: inherit; }
.codestate.err { color: #ff7b72; }
.codestate.warn { color: var(--gold); }
.anonbox { display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; }
.anonbox input { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 7px; padding: 9px 11px; font-size: 14px; outline: none; }
.anonbox input:focus { border-color: var(--gold); }
.anonhint { font-size: 11px; color: var(--muted); }
.submit { padding: 13px; background: var(--gold); color: #1a1300; border: none; border-radius: var(--radius); font-size: 15px; font-weight: 700; cursor: pointer; }
.submit:hover { background: var(--gold2); }
.submit:disabled { background: var(--bg3); color: var(--muted); cursor: not-allowed; }

/* ---------- toast / misc ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--green); color: #fff; padding: 12px 22px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: var(--red); }
/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.82); backdrop-filter: blur(4px); padding: 24px; }
.lightbox.show { display: flex; }
.lb-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 92vw; }
.lb-inner img { max-width: min(520px, 88vw); max-height: 74vh; border-radius: 14px; box-shadow: 0 12px 50px rgba(0,0,0,.6); }
.lb-cap { color: var(--text); text-align: center; font-size: 15px; line-height: 1.5; }
.lb-cap b { color: var(--gold2); }
.lb-cap .muted { color: var(--muted); }
.lb-close { position: absolute; top: -10px; right: -10px; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 50%; cursor: pointer; font-size: 22px; line-height: 1; }
.lb-close:hover { border-color: var(--gold); color: var(--gold2); }
.lb-add { padding: 11px 26px; background: var(--gold); color: #1a1300; border: none; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; }
.lb-add:hover { background: var(--gold2); }

.notice { background: var(--bg3); border: 1px solid var(--line); border-left: 3px solid var(--gold); padding: 10px 14px; border-radius: 8px; font-size: 13px; color: var(--muted); margin: 0 24px 4px; }
.loading { text-align: center; color: var(--muted); padding: 60px; }
#gbtn { min-height: 40px; }
