:root {
  --font: "Geist", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --mono: "Geist Mono", "Noto Sans TC", ui-monospace, monospace;

  --r-tag: 6px;
  --r-control: 10px;
  --r-card: 14px;
  --r-ticket: 16px;
  --r-inset: 4px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 140ms;
  --base: 200ms;
  --slow: 320ms;

  color-scheme: light;
  --bg-deep: #ffffff;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --raised: #eceff4;
  --raised-hover: #e1e5ec;
  --line: rgb(17 24 39 / 0.08);
  --line-strong: rgb(17 24 39 / 0.16);

  --text: #111827;
  --text-2: #4b5565;
  --text-3: #636c80;

  --accent: #ad4e05;
  --on-accent: #ffffff;

  --positive: #15803d;
  --negative: #dc2626;
  --negative-text: #b91c1c;
  --on-negative: #ffffff;

  --paper: #ffefd0;
  --ink: #111827;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-deep: #07080d;
  --bg: #0b0d14;
  --surface: #11141c;
  --raised: #1a1e28;
  --raised-hover: #232834;
  --line: rgb(238 240 245 / 0.08);
  --line-strong: rgb(238 240 245 / 0.16);

  --text: #eef0f5;
  --text-2: #a3a9b8;
  --text-3: #7a8296;

  --accent: #f5a524;
  --on-accent: #0b0d14;

  --positive: #4cc38a;
  --negative: #e5484d;
  --negative-text: #ff6b70;
  --on-negative: #0b0d14;

  --paper: #ffffff;
  --ink: #0b0d14;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

h1,
h2 {
  margin: 0;
  font-weight: 500;
  line-height: 1.4;
  text-wrap: balance;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

p,
figure {
  margin: 0;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.figure {
  font-family: var(--mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

main.container {
  padding-top: 24px;
  padding-bottom: 64px;
}

.site-header {
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
}

.site-header nav,
.theme-form {
  display: flex;
  gap: 8px;
}

.site-header nav {
  margin-left: auto;
}

.brand,
.site-header nav a,
.theme-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  border-radius: var(--r-control);
  background: none;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.brand {
  margin-left: -4px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.brand:hover,
.brand[aria-current="page"],
.site-header nav a[aria-current="page"] {
  background: var(--raised);
  color: var(--text);
}

.site-header nav a,
.theme-form button {
  color: var(--text-2);
}

.theme-form button {
  margin-right: -8px;
}

.site-header nav a:hover,
.theme-form button:hover {
  color: var(--text);
}

.jump-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r-control);
  background: var(--text);
  color: var(--bg);
  font-weight: 500;
  text-decoration: none;
}

.jump-link:focus {
  top: 8px;
}

.flash {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--raised);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  animation: rise var(--slow) var(--ease);
  scroll-margin: 16px;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--positive);
}

.flash-error .dot {
  background: var(--negative);
}

.btn,
.btn-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease),
    color var(--fast) var(--ease), transform var(--fast) var(--ease), opacity var(--fast) var(--ease);
}

.btn:active,
.btn-text:active {
  transform: scale(0.98);
}

.btn {
  background: var(--raised);
  border-color: var(--line);
}

.btn:hover {
  background: var(--raised-hover);
  border-color: var(--line-strong);
}

.btn-primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--text-2);
  border-color: var(--text-2);
}

.btn-text {
  padding: 0 8px;
  color: var(--text-2);
}

.btn-text:hover {
  background: var(--raised);
  color: var(--text);
}

.btn-danger {
  color: var(--negative-text);
}

.btn-danger:hover {
  background: var(--raised);
  color: var(--negative-text);
}

.btn-danger-solid {
  background: var(--negative);
  border-color: var(--negative);
  color: var(--on-negative);
}

.btn-danger-solid:hover {
  background: var(--negative-text);
  border-color: var(--negative-text);
}

.btn-square {
  width: 44px;
  padding: 0;
  font-size: 18px;
}

.btn-block {
  width: 100%;
}

.page-head {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.lead {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}

.card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}

.list {
  display: grid;
  gap: 16px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 8px;
  border-radius: var(--r-tag);
  background: var(--raised);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.4;
}

.meta {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}

.label {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
}

.detail {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.detail .figure {
  color: var(--text);
  white-space: nowrap;
}

.empty {
  display: grid;
  justify-items: start;
  gap: 16px;
  padding: 32px 20px;
}

.empty p {
  color: var(--text-2);
}

.store-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.btn-text[aria-pressed="true"] {
  background: var(--raised);
  color: var(--text);
}

.item {
  display: grid;
  gap: 16px;
}

.item-info {
  display: grid;
  gap: 8px;
}

.item-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

.price-now {
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}

.price s {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
}

.save {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.4;
}

.sold-out .price-now {
  color: var(--text-2);
}

.sold-out .save {
  color: var(--text-3);
}

.stock {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.4;
}

.ticks {
  display: inline-flex;
  gap: 4px;
}

.ticks:empty {
  display: none;
}

.ticks i {
  --tick: var(--text-2);
  width: 4px;
  height: 12px;
  border: 1px solid transparent;
  border-radius: 2px;
  background-color: var(--tick);
}

.ticks-low i {
  --tick: var(--accent);
}

.ticks i.taken {
  background-color: transparent;
  border-color: var(--tick);
}

.item-note {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text-3);
  font-size: 14px;
  line-height: 1.5;
}

.cart-layout {
  display: grid;
  gap: 16px;
}

.cart-lines {
  padding: 0 20px;
}

.cart-line {
  display: grid;
  grid-template-areas: "info subtotal" "actions actions";
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 16px;
  padding: 16px 0;
}

.cart-line + .cart-line {
  border-top: 1px solid var(--line);
}

.line-info {
  grid-area: info;
  display: grid;
  gap: 4px;
  align-content: center;
}

.cart-line h2 {
  font-size: 16px;
}

.unit {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
}

.subtotal {
  grid-area: subtotal;
  display: grid;
  justify-items: end;
}

.line-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty {
  min-width: 2ch;
  font-size: 16px;
  text-align: center;
}

.checkout {
  display: grid;
  gap: 8px;
}

.checkout-total {
  justify-self: end;
  font-size: 28px;
  line-height: 1;
}

.checkout-note {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}

.checkout form {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.ticket {
  display: grid;
  border-radius: var(--r-ticket);
  overflow: hidden;
}

.ticket-face {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--r-ticket) var(--r-ticket) 0 0;
  background: var(--surface);
}

.ticket-stub {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  border: 1px solid var(--line);
  border-top: 1px dashed var(--text-3);
  border-radius: 0 0 var(--r-ticket) var(--r-ticket);
  background: var(--paper);
  color: var(--ink);
}

.ticket-stub::before,
.ticket-stub::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
}

.ticket-stub::before {
  top: -8.5px;
  left: -8.5px;
}

.ticket-stub::after {
  top: -8.5px;
  right: -8.5px;
}

.order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.status-muted {
  color: var(--text-3);
}

.order-store {
  display: grid;
  gap: 4px;
  font-weight: 500;
}

.order-store .meta {
  font-weight: 400;
}

.order-lines {
  border-top: 1px solid var(--line);
}

.order-lines li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.order-lines .detail {
  margin-top: 4px;
  color: var(--text-2);
}

.order-lines .detail .label,
.order-lines .detail .figure {
  color: inherit;
}

.order-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.order-total .figure {
  font-size: 22px;
  line-height: 1;
}

.amount {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.pay {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.4;
}

.ticket-muted,
.ticket-muted h2 {
  color: var(--text-2);
}

.qr {
  text-align: center;
}

.qr svg {
  display: block;
  margin: 0 auto;
}

.qr figcaption {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.cancel summary {
  justify-self: start;
  list-style: none;
}

.cancel summary::-webkit-details-marker {
  display: none;
}

.cancel-confirm {
  --rise: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-inset);
  background: var(--bg);
}

.cancel-confirm p {
  flex: 1 1 100%;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}

details[open] .cancel-confirm {
  animation: rise var(--base) var(--ease);
}

@media (min-width: 640px) {
  .container {
    padding: 0 24px;
  }

  .brand,
  .site-header nav a,
  .theme-form button {
    padding: 0 8px;
  }

  .brand {
    margin-left: -8px;
  }

  .item {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .cart-line {
    grid-template-areas: "info actions subtotal";
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
  }

  .line-actions {
    justify-content: flex-start;
    gap: 8px;
  }

  .ticket {
    grid-template-columns: minmax(0, 1fr) 200px;
  }

  .ticket-face {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    border-radius: var(--r-ticket) 0 0 var(--r-ticket);
  }

  .ticket-stub {
    border-top: 1px solid var(--line);
    border-left: 1px dashed var(--text-3);
    border-radius: 0 var(--r-ticket) var(--r-ticket) 0;
  }

  .ticket-stub::after {
    top: auto;
    right: auto;
    bottom: -8.5px;
    left: -8.5px;
  }
}

@media (min-width: 1024px) {
  .container {
    padding: 0 32px;
  }

  main.container {
    padding-top: 32px;
  }

  h1 {
    font-size: 32px;
  }

  .page-head {
    margin-bottom: 32px;
  }

  .btn,
  .btn-text,
  .brand,
  .site-header nav a,
  .theme-form button {
    min-height: 40px;
  }

  .btn-square {
    min-height: 44px;
  }

  .item-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cart-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 24px;
    align-items: start;
  }

  .checkout-total {
    font-size: 32px;
  }
}

@view-transition {
  navigation: auto;
}

::view-transition-group(*),
::view-transition-old(*),
::view-transition-new(*) {
  animation-duration: var(--base);
  animation-timing-function: var(--ease);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(var(--rise, 8px));
  }
}

.ticks i.just-taken {
  animation: take var(--slow) var(--ease) var(--base) backwards;
}

@keyframes take {
  0% {
    background-color: var(--tick);
    border-color: transparent;
    transform: scaleY(1);
  }
  45% {
    transform: scaleY(0.5);
  }
  100% {
    background-color: transparent;
    border-color: var(--tick);
    transform: scaleY(1);
  }
}

.cart-bump {
  animation: bump var(--slow) var(--ease) var(--base) backwards;
}

@keyframes bump {
  45% {
    transform: scale(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  * {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}
