:root {
  color-scheme: light;
  --ink: #241c16;
  --muted: #74685e;
  --line: #eadfd3;
  --paper: #f6f1ea;
  --card: #fffdfb;
  --accent: #8d3a2c;
  --accent-soft: #f6e4dc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: #e7dfd4;
}

.phone {
  width: min(430px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}

.top {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(246, 241, 234, 0.94);
  backdrop-filter: blur(10px);
}

#back {
  flex: none;
  margin-left: -6px;
  padding: 6px 8px 6px 2px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

#back[hidden] { display: none; }
#back::before { content: "‹ "; }

.top.has-back .top-copy {
  position: absolute;
  left: 72px;
  right: 72px;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: env(safe-area-inset-top);
  pointer-events: none;
}

.top.has-back h1 { margin: 0; text-align: center; }

.crumb {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.top h1 {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 650;
}

.tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 4;
  transform: translateX(-50%);
  width: min(430px, 100%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}

.tabs a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  text-decoration: none;
  text-align: center;
  font-size: 11px;
  padding: 6px 0 4px;
}

.tabs svg, #fit-float svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.tabs a.active { color: var(--accent); font-weight: 650; }

#cart-count {
  position: absolute;
  top: 1px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
}

#cart-count:empty { display: none; }

.pad { padding: 0 14px 18px; }

.banner, .card, .row, .notice {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.banner {
  padding: 16px;
  background: linear-gradient(160deg, #fff, #f8ebe4);
}

.banner strong { display: block; font-size: 18px; margin-bottom: 6px; }
.banner p, .muted, .status { color: var(--muted); line-height: 1.5; }

.chips, .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.chips { margin: 12px 0; }

.chip, button, .btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
}

.chip.active, .btn.primary, button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button, .btn { cursor: pointer; }
button:disabled { opacity: 0.45; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.product, .shop {
  display: block;
  padding: 8px;
  color: inherit;
  text-decoration: none;
}

.product img, .hero img {
  width: 100%;
  background: #fff;
  object-fit: contain;
}

.product img { height: 150px; border-radius: 10px; }
.product b, .shop b { display: block; margin-top: 8px; }
.product.selected { outline: 2px solid var(--accent); }
.price { color: var(--accent); font-weight: 700; }
.origin { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
.price-row { margin: 6px 0; }
.zone { margin: 16px 0 4px; }
.zone-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.zone-head b { font-size: 16px; }
.zone-head span { color: var(--muted); font-size: 12px; }
.rail { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.rail-card { flex: 0 0 132px; color: inherit; text-decoration: none; }
.rail-card img { width: 132px; height: 132px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.rail-card b { display: block; margin-top: 6px; font-size: 13px; }

.shop { padding: 14px; margin-bottom: 10px; }
.shop span { color: var(--muted); font-size: 13px; }

.carousel { position: relative; overflow: hidden; margin: 0 14px; border-radius: 16px; }
.carousel-track { display: flex; transition: transform 0.45s ease; }
.carousel a { position: relative; flex: 0 0 100%; display: block; color: #fff; text-decoration: none; }
.carousel img { width: 100%; height: 168px; object-fit: cover; background: #efe7de; }
.carousel a span { position: absolute; left: 14px; bottom: 14px; display: flex; flex-direction: column; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45); }
.carousel a b { font-size: 18px; }
.carousel-dots { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 5px; }
.carousel-dots button { width: 6px; height: 6px; padding: 0; border: 0; border-radius: 99px; background: rgba(255, 255, 255, 0.65); }
.carousel-dots button.active { width: 14px; background: #fff; }

.store { display: grid; grid-template-columns: 88px 1fr; gap: 12px; align-items: center; padding: 10px; margin-bottom: 10px; }
.store img, .store-hero img { width: 88px; height: 88px; object-fit: cover; border-radius: 10px; background: #fff; }
.store b, .store-hero b { display: block; margin: 0; }
.store span, .store-hero span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.store-hero { display: grid; grid-template-columns: 72px minmax(0, 1fr) 84px; gap: 10px; align-items: center; padding: 10px; margin-bottom: 12px; }
.store-hero img { width: 72px; height: 72px; }
#shop-qr { line-height: 0; justify-self: end; }

.balance { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; margin-bottom: 8px; }
.balance span { color: var(--muted); font-size: 13px; }
.balance strong { display: block; margin-top: 2px; font-size: 26px; }
.ledger-plus { color: #2f7d4a; }
.line small { color: var(--muted); }

.profile { display: flex; align-items: center; gap: 12px; padding: 6px 2px 18px; }
.avatar { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 22px; }
.profile b { display: block; font-size: 18px; }
.profile span { color: var(--muted); font-size: 13px; }
.entries { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.entries a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 92px;
  padding: 14px 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
  text-align: center;
  font-size: 13px;
}
.entries svg { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.entry-icon { position: relative; display: flex; }
.entries em:empty { display: none; }
.entries em {
  position: absolute;
  top: -6px;
  right: -12px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-style: normal;
  font-size: 10px;
  line-height: 16px;
}

.hero { padding: 12px; }
.hero img { height: 280px; border-radius: 12px; }
.hero-shop { display: inline-block; margin: 10px 0 0; color: var(--muted); font-size: 13px; text-decoration: none; }

.bar {
  position: sticky;
  bottom: calc(62px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  padding: 10px 0;
  background: linear-gradient(transparent, var(--paper) 20%);
}

.bar .btn, .bar button { flex: 1; text-align: center; border-radius: 12px; padding: 12px 8px; }

.line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.cart-item, .order {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  padding: 10px;
  margin-bottom: 10px;
}

a.order, a.store {
  color: inherit;
  text-decoration: none;
}

.cart-item img, .order img { width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: 8px; }

.qty { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.qty button { width: 28px; height: 28px; padding: 0; border-radius: 8px; }

label { display: block; margin: 12px 0; font-size: 14px; }
input, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  background: #fff;
}

.notice { padding: 12px; margin: 12px 0; font-size: 13px; line-height: 1.55; }
.fit-strip { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.fit-strip article {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.fit-strip img { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; background: #fff; }
.fit-strip b { flex: 1; margin: 0; font-size: 14px; text-align: left; }
.fit-strip button, .fit-row > button { flex: none; margin: 0; padding: 6px 12px; border-radius: 8px; font-size: 13px; }
.fit-row { grid-template-columns: 72px 1fr auto; align-items: center; }

.match-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
  font-weight: 650;
}
.match-entry span { color: var(--muted); font-size: 13px; font-weight: 400; }
.measure { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.measure label { margin: 8px 0; }
.sku-picks { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.sku-picks button { margin: 0; padding: 8px 12px; border-radius: 12px; background: #fff; line-height: 1.3; }
.sku-picks button small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.sku-picks button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.sku-picks button.on small { color: rgba(255, 255, 255, 0.85); }
.dialog-card .sku-picks { margin-bottom: 14px; }

.want-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.want-chips button { margin: 0; padding: 8px 14px; border-radius: 999px; background: #fff; }
.want-chips button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.advice { margin: 8px 0 0; color: var(--ink); font-size: 13px; line-height: 1.6; }
.advice p { margin: 0; }

.photo-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.photo-thumb {
  width: 64px;
  height: 86px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.photo-row .upload { margin: 0; }
.photo-row .status { margin: 6px 0 0; }

.look {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 8px;
  align-items: start;
  margin: 12px 0;
}
.look-result {
  width: 100%;
  max-height: 460px;
  object-fit: contain;
  object-position: top center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
}
.look-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 460px;
  overflow: auto;
}
.look-item {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: center;
}
.look-item img { width: 100%; height: 64px; object-fit: contain; background: #fff; }
.look-item b { display: block; margin-top: 4px; font-size: 12px; line-height: 1.3; }
.look-item .price { font-size: 12px; }
.look-item button { width: 100%; margin-top: 6px; padding: 6px 0; border-radius: 8px; font-size: 12px; }

.loading {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 9;
  transform: translateX(-50%);
  width: min(430px, 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(246, 241, 234, 0.94);
  text-align: center;
  padding: 24px;
}

.loading strong { font-size: 18px; }
.loading span:last-child { color: var(--muted); font-size: 14px; line-height: 1.5; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.upload input { display: none; }
.status { min-height: 1.4em; font-size: 14px; }
h2 { font-size: 16px; margin: 16px 0 8px; }

.product a { display: block; color: inherit; text-decoration: none; }
.fit-add { width: 100%; margin-top: 8px; border-radius: 10px; }
.fit-add.in { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

#fit-float {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  transform: translateX(calc(min(215px, 50vw) - 100% - 12px));
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(141, 58, 44, 0.28);
}

#fit-float[hidden] { display: none; }
#fit-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: #fff;
  color: var(--accent);
  font-style: normal;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}
#fit-count:empty { display: none; }

#fit-sheet { position: fixed; inset: 0; z-index: 7; }
#fit-sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(36, 28, 22, 0.12); }
.sheet-panel {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(430px, 100%);
  max-height: 72dvh;
  overflow: auto;
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: #fffdfb;
  box-shadow: 0 -10px 28px rgba(36, 28, 22, 0.12);
}
.sheet-head, .sheet-go { display: flex; align-items: center; justify-content: space-between; }
.sheet-go { justify-content: center; margin-top: 8px; }

#dialog {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(36, 28, 22, 0.4);
}
#dialog[hidden] { display: none; }
.dialog-card { width: min(340px, 100%); padding: 18px; border-radius: 16px; background: #fff; }
.dialog-card p { margin: 0 0 14px; line-height: 1.55; }

#toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  top: calc(12px + env(safe-area-inset-top));
  transform: translateX(-50%);
  max-width: min(390px, calc(100% - 28px));
  padding: 10px 14px;
  border-radius: 999px;
  background: #241c16;
  color: #fff;
  font-size: 13px;
}
#toast[hidden] { display: none; }

.poster {
  margin-top: 8px;
  padding: 22px 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, #8d3a2c, #5c241c 58%, #241c16);
  color: #fff;
  text-align: center;
}
.poster strong { display: block; font-size: 22px; margin: 4px 0; }
.poster p { color: rgba(255, 255, 255, 0.86); }
.poster .qr { display: inline-block; margin: 8px 0; padding: 10px; border-radius: 12px; background: #fff; line-height: 0; }
.record-view img { width: 100%; border-radius: 12px; background: #fff; }
