:root {
  --ink: #23211f;
  --muted: #706b64;
  --line: #d9d2c8;
  --paper: #f7f4ee;
  --panel: #fffdf8;
  --accent: #225d63;
  --danger: #9f3f36;
  --gold: #b6822d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

header {
  padding: 18px clamp(18px, 5vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 244, 238, 0.94);
  position: sticky;
  top: 0;
  z-index: 2;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(1.65rem, 3.4vw, 2.35rem);
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
  gap: 18px;
  padding: 24px clamp(18px, 5vw, 56px) 48px;
}

.product-grid {
  display: grid;
  align-content: start;
  gap: 22px;
}

.category-section h2 {
  margin-bottom: 12px;
  font-size: 1.25rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.card,
aside {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(42, 36, 28, 0.09);
}

.card {
  overflow: hidden;
}

.image {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: #e5ded2;
  color: var(--muted);
  font-weight: 800;
}

.image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.info {
  padding: 14px;
}

.price {
  margin-bottom: 6px;
  color: var(--danger);
  font-size: 1.12rem;
  font-weight: 900;
}

.note {
  min-height: 1.4em;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.expires {
  margin: 6px 0 0;
  color: var(--gold);
  font-size: 0.86rem;
  font-weight: 800;
}

.release-date {
  margin: 6px 0 0;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
}

.qty {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  font-weight: 900;
}

.qty button,
output {
  height: 40px;
}

output {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-weight: 900;
}

aside {
  align-self: start;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 18px;
}

.drawer-close,
.mobile-cart-bar {
  display: none;
}

.cart-lines {
  display: grid;
  flex: 0 0 auto;
  gap: 10px;
  margin-bottom: 14px;
  padding-right: 4px;
}

.cart-line {
  display: grid;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(217, 210, 200, 0.75);
}

.cart-line:last-child {
  border-bottom: 0;
}

.cart-item-name {
  font-weight: 850;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.cart-item-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.cart-item-price {
  color: var(--danger);
  font-weight: 900;
  white-space: nowrap;
}

.cart-actions {
  display: grid;
  grid-template-columns: 34px 42px 34px 34px;
  gap: 6px;
  align-items: center;
}

.cart-actions button,
.cart-actions output {
  width: 34px;
  height: 34px;
  min-width: 0;
}

.cart-actions output {
  width: 42px;
}

.cart-remove {
  color: var(--danger);
}

.total {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  margin-bottom: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.total strong {
  color: var(--danger);
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  background: #fff;
}

.submit {
  width: 100%;
  min-height: 44px;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.status {
  margin-top: 12px;
  color: var(--accent);
  font-weight: 800;
}

.social-panel {
  display: none;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.social-panel.is-visible {
  display: block;
}

.social-panel h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.qr-card {
  display: none;
  gap: 8px;
  text-align: center;
}

.qr-card.is-visible {
  display: grid;
}

.qr-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 8px;
}

.qr-card span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

@media (max-width: 1100px), (hover: none), (pointer: coarse) {
  body {
    padding-bottom: 86px;
  }

  main {
    grid-template-columns: 1fr;
  }

  aside {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    width: auto;
    max-height: min(84vh, 760px);
    overflow-y: auto;
    border-radius: 12px 12px 0 0;
    padding: 18px;
    transform: translateY(calc(100% + 16px));
    transition: transform 180ms ease;
  }

  body.cart-open aside {
    transform: translateY(0);
  }

  body.cart-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 4;
    background: rgba(35, 33, 31, 0.32);
  }

  .drawer-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    color: var(--muted);
  }

  .mobile-cart-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 10px 14px;
    border-color: var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 10px 26px rgba(42, 36, 28, 0.22);
  }

  body.cart-open .mobile-cart-bar {
    display: none;
  }

  .mobile-cart-bar strong,
  .mobile-cart-bar span {
    display: block;
    line-height: 1.25;
  }
}

@media (min-width: 1101px) and (hover: hover) and (pointer: fine) {
  main {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 420px);
  }

  aside {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
  }
}
