:root {
  --brand-primary: #89679f;
  --brand-primary-dark: #765889;
  --brand-primary-soft: #f3eff6;
  --brand-ink: #302c35;
  --brand-navy: var(--brand-ink);
  --brand-background: #f7f6f8;
  --brand-surface: #ffffff;
  --brand-border: #e6e2e9;
  --brand-accent-text: #89679f;
  --brand-warm-white: var(--brand-background);
  --brand-line: var(--brand-border);
  --ink: var(--brand-navy);
  --muted: #746f79;
  --cream: var(--brand-background);
  --paper: var(--brand-surface);
  --peach: #c9574f;
  --peach-dark: #ef0025;
  --butter: #f1c84b;
  --gold-text: #b87900;
  --sage: #32685d;
  --line: var(--brand-border);
  --winter-blue: var(--brand-navy);
  --sky-blue: #9b74b4;
  --shadow: 0 8px 24px rgba(48, 44, 53, 0.08);
}

body[data-storefront-theme="gold"] {
  --brand-primary: #d6a72c;
  --brand-primary-dark: #72560c;
  --brand-primary-soft: #fff6d8;
  --brand-ink: #3f3827;
  --brand-background: #fbf8ee;
  --brand-surface: #fffdf7;
  --brand-border: #e6dcc2;
  --brand-accent-text: #8a6813;
}

body[data-storefront-theme="violet"] {
  --brand-primary: #89679f;
  --brand-primary-dark: #765889;
  --brand-primary-soft: #f3eff6;
  --brand-ink: #302c35;
  --brand-background: #f7f6f8;
  --brand-surface: #ffffff;
  --brand-border: #e6e2e9;
  --brand-accent-text: #89679f;
}

body[data-storefront-theme="pink"] {
  --brand-primary: #d881a3;
  --brand-primary-dark: #9a4669;
  --brand-primary-soft: #fff0f5;
  --brand-ink: #452f38;
  --brand-background: #fff8fa;
  --brand-surface: #ffffff;
  --brand-border: #efdbe3;
  --brand-accent-text: #a95073;
}

* { box-sizing: border-box; }
html { background: var(--cream); color: var(--ink); font-family: "Noto Sans TC", sans-serif; }
body { margin: 0; min-height: 100vh; background: var(--brand-background); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.site-header { position: sticky; top: 0; z-index: 20; display: flex; min-height: 58px; align-items: center; justify-content: space-between; padding: 9px max(16px, env(safe-area-inset-left)); background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); color: var(--ink); backdrop-filter: blur(12px); }
.provider-brand { display: flex; min-width: 0; align-items: center; gap: 7px; color: var(--ink); font-size: .76rem; font-weight: 700; }
.provider-brand img { width: 30px; height: 30px; flex: none; border-radius: 5px; object-fit: cover; }
.provider-brand span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.eyebrow { margin: 0 0 3px; color: var(--brand-accent-text); font-size: .68rem; font-weight: 700; letter-spacing: .15em; }
.header-link { min-height: 40px; padding: 8px 4px 8px 12px; border: 0; background: transparent; color: var(--brand-primary-dark); font-size: .82rem; font-weight: 700; cursor: pointer; }
.header-link:focus-visible { border-radius: 6px; outline: 3px solid rgba(137,103,159,.24); outline-offset: 1px; }
.text-button { border: 0; background: transparent; color: var(--brand-accent-text); font-weight: 700; cursor: pointer; }

main { width: min(100%, 760px); margin: auto; padding: 0 16px 110px; }
.storefront-hero { position: relative; overflow: hidden; margin: 0 -16px; aspect-ratio: 16/7; background: #eee9e2; }
.storefront-hero img { display: block; width: 100%; height: 100%; opacity: 1; object-fit: cover; object-position: center 58%; transition: opacity .24s ease; }
.storefront-hero.is-loading { background: linear-gradient(110deg, #f1ebf5 18%, #faf7fc 38%, #eee6f3 58%); background-size: 220% 100%; animation: storefront-image-loading 1.35s ease-in-out infinite; }
.storefront-hero.is-loading img { opacity: 0; }
.store-identity { position: relative; z-index: 2; display: grid; grid-template-columns: 64px minmax(0,1fr); gap: 14px; align-items: center; margin: -25px 0 0; padding: 18px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); box-shadow: var(--shadow); }
.store-mark { width: 64px; height: 64px; border-radius: 50%; background: #eee6f3; opacity: 1; object-fit: cover; transition: opacity .24s ease; }
.store-mark.is-loading { opacity: .18; animation: storefront-mark-loading 1.35s ease-in-out infinite alternate; }
.store-identity h1 { margin: 0; color: var(--ink); font-size: 1.2rem; line-height: 1.3; letter-spacing: -.02em; }
.store-identity p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }
.store-identity .brand-contact { color: var(--brand-primary-dark); font-size: .72rem; font-weight: 700; }
@keyframes storefront-image-loading { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes storefront-mark-loading { from { opacity: .14; } to { opacity: .34; } }
@media (prefers-reduced-motion: reduce) {
  .storefront-hero.is-loading, .store-mark.is-loading { animation: none; }
  .storefront-hero img, .store-mark { transition: none; }
}
.preorder-rules { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px; align-items: center; margin: 22px 2px 0; padding: 0 0 20px; border-bottom: 1px solid var(--line); }
.preorder-rules h2 { margin: 0 0 8px; font-size: 1rem; }
.preorder-rules p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--muted); font-size: .78rem; line-height: 1.7; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.preorder-rules.expanded p { display: block; overflow: visible; }
.preorder-rules button { min-height: 44px; padding: 6px 0 6px 8px; border: 0; background: transparent; color: var(--brand-primary-dark); font-size: .75rem; font-weight: 700; white-space: nowrap; cursor: pointer; }
.preorder-rules button span { margin-left: 3px; font-size: 1.15em; }
.catalog-search { position: relative; display: block; margin: 20px 0 10px; }
.catalog-search > img { position: absolute; z-index: 1; top: 50%; left: 14px; width: 22px; height: 22px; transform: translateY(-50%); object-fit: contain; pointer-events: none; }
.catalog-search input { width: 100%; min-height: 48px; padding: 12px 15px 12px 43px; border: 1px solid var(--brand-line); border-radius: 10px; background: var(--paper); color: var(--ink); outline: none; }
.catalog-search input::placeholder { color: #aaa5ae; }
.catalog-search input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(137,103,159,.18); }

.section-heading { display: flex; align-items: end; justify-content: space-between; margin: 24px 2px 13px; }
.section-heading h2 { margin: 0; font-size: 1.18rem; }
.section-heading > span { color: var(--muted); font-size: .8rem; }
.category-chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.category-chips button { flex: none; min-height: 40px; padding: 8px 17px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); font-size: .76rem; font-weight: 600; cursor: pointer; }
.category-chips button.active { border-color: #bfa9cf; background: #fbf9fc; color: var(--brand-primary-dark); }
.category-chips button:focus-visible { outline: 3px solid rgba(137,103,159,.2); outline-offset: 1px; }
.status-panel { padding: 26px 14px; color: var(--muted); text-align: center; }

.product-grid { display: grid; gap: 0; border-top: 1px solid var(--line); }
.product-card { display: grid; grid-template-columns: 116px minmax(0,1fr); gap: 15px; min-height: 142px; padding: 12px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; cursor: pointer; transition: background .16s ease; }
.product-card:active { background: var(--brand-primary-soft); }
.product-card > img { display: block; width: 116px; height: 116px; align-self: center; border-radius: 8px; object-fit: cover; background: #f1eef3; }
.product-card-body { display: flex; min-width: 0; flex-direction: column; padding: 2px 0; }
.category-label { display: inline-block; color: var(--brand-accent-text); font-size: .68rem; font-weight: 700; }
.product-card h3 { display: -webkit-box; margin: 5px 0 9px; overflow: hidden; color: var(--ink); font-size: .9rem; line-height: 1.38; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.product-card-footer { display: flex; gap: 10px; align-items: end; justify-content: space-between; margin-top: auto; }
.product-card .price { margin: 0; color: var(--brand-accent-text); font-size: 1rem; font-weight: 700; letter-spacing: -.02em; }
.card-add-button { flex: none; min-height: 40px; padding: 8px 0 6px 8px; border: 0; background: transparent; color: var(--brand-primary-dark); font-size: .72rem; font-weight: 700; cursor: pointer; }
.card-add-button:focus-visible { border-radius: 6px; outline: 3px solid rgba(137,103,159,.22); outline-offset: 1px; }
.product-card small { display: block; margin-top: 4px; color: var(--muted); font-size: .67rem; }

.cart-dock { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: rgba(247,243,250,.95); border-top: 1px solid var(--brand-line); backdrop-filter: blur(12px); }
.cart-dock button { display: flex; width: min(100%, 732px); margin: auto; padding: 14px 17px; align-items: center; justify-content: space-between; border: 1px solid var(--brand-primary-dark); border-radius: 8px; background: var(--brand-primary-dark); color: var(--paper); cursor: pointer; }
.cart-dock button span:last-child { color: #f0dff8; }
.cart-dock button span:last-child { font-size: .82rem; }

dialog { width: min(calc(100% - 24px), 560px); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 12px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 60px rgba(40,30,25,.24); }
dialog::backdrop { background: rgba(55,43,36,.52); backdrop-filter: blur(3px); }
.dialog-close { width: 38px; height: 38px; border: 0; border-radius: 50%; background: rgba(255,255,255,.92); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.product-dialog > form { position: absolute; z-index: 1; top: 12px; right: 12px; }
.product-dialog-gallery > img { display: block; width: 100%; max-height: 45vh; aspect-ratio: 4/3; object-fit: cover; background: #f1ebf5; }
.product-dialog-thumbnails { display: flex; gap: 7px; overflow-x: auto; padding: 8px 10px 1px; scrollbar-width: thin; }
.product-dialog-thumbnails:empty { display: none; }
.product-dialog-thumbnails button { flex: none; width: 56px; height: 56px; padding: 2px; overflow: hidden; border: 2px solid transparent; border-radius: 10px; background: white; }
.product-dialog-thumbnails button.active { border-color: var(--brand-primary); }
.product-dialog-thumbnails img { width: 100%; height: 100%; border-radius: 6px; object-fit: cover; }
.dialog-body { padding: 20px; }
.dialog-body h2 { margin: 5px 0; }
.twd-price { margin: 8px 0 12px; color: var(--brand-accent-text); font-size: 1.35rem; font-weight: 700; }
.product-description { color: var(--muted); font-size: .86rem; line-height: 1.65; white-space: pre-wrap; }
.field { display: grid; gap: 7px; margin: 14px 0; }
.field > span { font-size: .82rem; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(107,45,143,.26); }
.primary-button { width: 100%; padding: 14px 17px; border: 0; border-radius: 8px; background: var(--brand-primary-dark); color: var(--paper); font-weight: 700; cursor: pointer; }
.primary-button:disabled { opacity: .5; cursor: wait; }

.checkout-dialog { padding: 20px; }
.checkout-header { display: flex; align-items: start; justify-content: space-between; }
.checkout-header h2 { margin: 0; }
.checkout-header .dialog-close { background: var(--cream); }
.checkout-items { margin: 18px 0; border-top: 1px solid var(--line); }
.checkout-item { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.checkout-item img { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; background: #f1ebf5; }
.checkout-item strong, .checkout-item small { display: block; }
.checkout-item small { margin-top: 3px; color: var(--muted); }
.remove-item { border: 0; background: transparent; color: var(--peach-dark); cursor: pointer; }
.money-card { padding: 15px; border-radius: 8px; background: var(--brand-primary-soft); }
.money-card > div { display: flex; justify-content: space-between; padding: 5px 0; font-size: .88rem; }
.money-card .deposit-row { margin: 5px -7px; padding: 9px 7px; border-radius: 10px; background: white; color: var(--brand-accent-text); }
.money-card small { display: block; margin-top: 6px; color: var(--muted); line-height: 1.5; }
.form-title { margin: 24px 0 5px; }
.transfer-info { margin: 16px 0 4px; padding: 13px; border: 1px dashed var(--ink); border-radius: 8px; background: var(--paper); }
.transfer-info strong { color: var(--brand-accent-text); font-size: .82rem; }
.transfer-info p { margin: 5px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.55; white-space: pre-wrap; }
.order-first-note { margin: 16px 0 4px; padding: 13px; border-left: 4px solid var(--brand-primary); border-radius: 0 6px 6px 0; background: var(--brand-primary-soft); }
.order-first-note strong { color: var(--winter-blue); font-size: .86rem; }
.order-first-note p { margin: 5px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.55; }
.payment-order-summary { display: grid; grid-template-columns: 1fr auto; gap: 7px 14px; margin: 18px 0 10px; padding: 14px; border-radius: 8px; background: var(--cream); }
.payment-order-summary span { color: var(--muted); font-size: .78rem; }
.payment-order-summary strong { text-align: right; }
.later-button { width: 100%; margin-top: 9px; padding: 12px; border: 0; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.agreement { display: flex; gap: 9px; align-items: start; margin: 20px 0; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.agreement input { flex: none; margin-top: 3px; }
.submit-button { margin-bottom: 0; }
.order-submit-status { position: relative; margin: 10px 0 max(0px, env(safe-area-inset-bottom)); padding: 12px 13px 12px 40px; border: 1px solid #b8d1de; border-radius: 13px; background: #e8f3f7; color: var(--winter-blue); font-size: .8rem; font-weight: 600; line-height: 1.6; }
.order-submit-status::before { position: absolute; top: 14px; left: 14px; width: 15px; height: 15px; border: 2px solid rgba(71,116,142,.25); border-top-color: var(--winter-blue); border-radius: 50%; content: ""; animation: order-submit-spin .8s linear infinite; }
.order-submit-status.is-busy { border-color: #e1c67c; background: #fff8df; color: #765c16; }
.order-submit-status.is-busy::before { border-color: rgba(184,121,0,.22); border-top-color: var(--gold-text); }
@keyframes order-submit-spin { to { transform: rotate(360deg); } }

.sale-closed-dialog { width: min(calc(100% - 32px), 440px); overflow: hidden; text-align: center; }
.sale-closed-dialog::backdrop { background: rgba(31,43,50,.78); backdrop-filter: blur(8px); }
.sale-closed-content { padding: 34px 26px 38px; background: linear-gradient(160deg, #fffdf7, #e7f1f5); }
.sale-closed-icon { display: grid; width: 62px; height: 62px; margin: 0 auto 17px; place-items: center; border-radius: 50%; background: var(--winter-blue); color: white; font-size: 1.8rem; font-weight: 700; box-shadow: 0 8px 24px rgba(71,116,142,.28); }
.sale-closed-content .eyebrow { color: var(--peach-dark); }
.sale-closed-content h2 { margin: 7px 0 12px; font-size: 1.65rem; }
.sale-closed-content > p:last-child { margin: 0; color: var(--muted); line-height: 1.75; white-space: pre-wrap; }

.order-history-toolbar { display: flex; gap: 10px; align-items: end; justify-content: space-between; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.order-history-filters { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.order-history-filters button { flex: none; padding: 10px 8px 9px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-size: .75rem; font-weight: 700; cursor: pointer; }
.order-history-filters button.active { border-bottom-color: var(--brand-primary); color: var(--ink); }
.order-history-filters span { display: inline-block; min-width: 1.3em; margin-left: 2px; color: inherit; font-size: .68rem; text-align: center; }
.order-history-refresh { flex: none; margin-bottom: 7px; padding: 6px 8px; border: 1px solid var(--ink); border-radius: 6px; background: var(--paper); color: var(--ink); font-size: .7rem; font-weight: 700; cursor: pointer; }
.order-history-meta { margin: 12px 2px; color: var(--muted); font-size: .72rem; }
.order-list { display: grid; gap: 12px; }
.order-card { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.order-card summary { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 15px; cursor: pointer; list-style-position: inside; }
.order-card[open] summary { border-bottom: 1px solid var(--line); background: #f8f2fb; }
.order-card-heading { display: grid; gap: 4px; min-width: 0; }
.order-card-heading > strong { overflow: hidden; font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }
.order-card time { color: var(--muted); font-size: .7rem; }
.order-card-total { display: grid; gap: 2px; text-align: right; }
.order-card-total small { color: var(--muted); font-size: .64rem; }
.order-card-total b { color: var(--ink); font-size: .9rem; white-space: nowrap; }
.order-card-body { padding: 15px; }
.order-status { width: max-content; padding: 3px 6px; border-radius: 4px; background: var(--brand-primary-soft); color: var(--ink); font-size: .67rem; font-weight: 700; }
.order-card-completed .order-status { background: #dcece6; color: var(--sage); }
.order-card-cancelled .order-status { background: #ece9e6; color: #6f6863; }
.order-status.overdue { background: #f3e4e1; color: #9a3e36; }
.order-info-list { display: grid; gap: 0; margin: 0 0 14px; }
.order-info-list > div { display: grid; grid-template-columns: 88px minmax(0,1fr); gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.order-info-list dt { color: var(--muted); font-size: .76rem; }
.order-info-list dd { margin: 0; overflow-wrap: anywhere; font-size: .78rem; font-weight: 700; text-align: right; }
.order-items-summary { padding: 12px 0; }
.order-items-summary > span { color: var(--muted); font-size: .7rem; font-weight: 700; }
.order-items-summary pre { margin: 6px 0; color: var(--ink); font: inherit; font-size: .8rem; font-weight: 700; line-height: 1.6; white-space: pre-wrap; }
.order-items-summary small { color: var(--muted); font-size: .68rem; }
.order-shortage-notice { display: grid; gap: 3px; margin: 0 0 12px; padding: 10px 11px; border-radius: 11px; background: #fff3df; color: #795d34; font-size: .72rem; }
.order-shortage-notice strong { color: #b35d35; }
.order-money { display: grid; gap: 7px; padding-top: 12px; border-top: 1px solid var(--line); }
.order-money div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.order-money span { color: var(--muted); font-size: .76rem; }
.order-money strong { font-size: .84rem; }
.order-money div:last-child strong { color: var(--brand-accent-text); font-size: 1rem; }
.payment-action { width: 100%; margin-top: 13px; padding: 11px; border: 1px solid var(--brand-primary-dark); border-radius: 7px; background: var(--brand-primary-dark); color: var(--paper); font-weight: 700; cursor: pointer; }
.payment-report-complete { display: grid; gap: 3px; margin-top: 13px; padding: 11px 12px; border: 1px solid var(--sky-blue); border-radius: 12px; background: #edf5f8; color: var(--winter-blue); font-size: .75rem; }
.payment-report-complete span { color: var(--muted); }
.mall-payment { margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--line); }
.mall-payment p { margin: 0 0 9px; color: var(--muted); font-size: .76rem; line-height: 1.55; }
.mall-payment .payment-action { display: block; margin-top: 0; background: var(--brand-primary-dark); color: var(--paper); text-align: center; text-decoration: none; }
.mall-payment-expired { color: #9a3e36 !important; font-weight: 700; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 92px; max-width: calc(100% - 32px); padding: 11px 15px; border-radius: 7px; background: var(--ink); color: var(--paper); font-size: .82rem; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 650px) {
  main { padding-top: 20px; }
  .storefront-hero { margin: 0; border-radius: 10px; }
  .store-identity { margin-right: 20px; margin-left: 20px; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
  .product-card h3 { font-size: .96rem; }
}
