/* 365 Showroom — WeShop-like structure (reference architecture) */
:root {
  --bg: #f2f3f5;
  --surface: #fff;
  --text: #1a1a1a;
  --muted: #8a8a8a;
  --line: #e8e8e8;
  --accent: #222;
  --header-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
}
button,
input {
  font: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}
img,
video {
  max-width: 100%;
  display: block;
}
button {
  cursor: pointer;
  border: 0;
  background: none;
}
.hidden {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid var(--line);
}
.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.topbar-right {
  justify-content: flex-end;
}
.topbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 46vw;
}
.shop-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ddd, #f5f5f5);
  border: 1px solid var(--line);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  position: relative;
}
.shop-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.shop-avatar .ph {
  font-size: 9px;
  text-align: center;
  line-height: 1.1;
  padding: 2px;
}
.shop-meta {
  min-width: 0;
}
.shop-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shop-sub {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-btn {
  height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tb-btn:hover {
  background: #f3f3f3;
}
.tb-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.tb-icon:hover {
  background: #f3f3f3;
}

/* ===== Home sections ===== */
.home {
  padding-bottom: calc(88px + var(--safe-b));
}
.banner {
  background: #111;
  color: #fff;
  padding: 18px 16px 16px;
  position: relative;
  overflow: hidden;
}
.banner::after {
  content: "PLACEHOLDER · Banner";
  position: absolute;
  right: 10px;
  top: 10px;
  font-size: 10px;
  opacity: 0.45;
  letter-spacing: 0.04em;
}
.banner h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 750;
}
.banner p {
  margin: 6px 0 0;
  font-size: 13px;
  opacity: 0.8;
}
.contact-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 12px;
  font-weight: 650;
}
.chip.ghost {
  background: #fff;
  color: #111;
  border: 1px solid var(--line);
}

.section {
  background: var(--surface);
  margin-top: 8px;
  padding: 12px 0 14px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 10px;
}
.section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
}
.section-head .more {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.ph-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 600;
  color: #b36b00;
  background: #fff6e5;
  border: 1px solid #f0d7a6;
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
}

/* category entry grid */
.cat-entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 12px;
}
@media (min-width: 720px) {
  .cat-entry-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.cat-entry {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fafafa;
  text-align: left;
  padding: 0;
}
.cat-entry .thumb {
  aspect-ratio: 1;
  background: #eee;
  position: relative;
}
.cat-entry .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cat-entry .label {
  padding: 8px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.cat-entry .count {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

/* horizontal product rails */
.rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.rail::-webkit-scrollbar {
  display: none;
}
.rail-card {
  flex: 0 0 118px;
  scroll-snap-align: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  text-align: left;
  padding: 0;
}
.rail-card .media {
  aspect-ratio: 3/4;
  background: #eee;
}
.rail-card .media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rail-card .t {
  padding: 6px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rail-card .p {
  padding: 0 6px 8px;
  font-size: 10px;
  color: var(--muted);
}

/* feeds + toolbar */
.list-shell {
  margin-top: 8px;
  background: var(--surface);
  min-height: 40vh;
}
.list-toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
  padding: 8px 8px 0;
}
.list-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 8px;
}
.list-title-row h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
}
.tool-actions {
  display: flex;
  gap: 4px;
}
.tool-actions button {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  background: #fff;
}
.tool-actions button.active {
  background: #111;
  color: #fff;
  border-color: #111;
}
.feeds {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 4px 10px;
}
.feed-btn {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}
.feed-btn.active {
  background: #111;
  color: #fff;
}

/* product grid */
.grid-wrap {
  padding: 8px;
}
.grid {
  display: grid;
  gap: 8px;
}
.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 900px) {
  .grid.cols-3 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .grid.cols-2 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  text-align: left;
  padding: 0;
}
.card:hover {
  box-shadow: var(--shadow);
}
.card-media {
  aspect-ratio: 3/4;
  background: #eee;
  position: relative;
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
}
.badge.video {
  left: auto;
  right: 6px;
}
.card-body {
  padding: 7px;
}
.card-title {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 14px;
}

/* floating */
.fab-col {
  position: fixed;
  right: 12px;
  bottom: calc(16px + var(--safe-b));
  z-index: 45;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fab {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.fab.light {
  background: #fff;
  color: #111;
  border: 1px solid var(--line);
}

/* overlays / drawers */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 60;
  display: none;
}
.overlay.open {
  display: block;
}
.drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(82vh, 720px);
  background: #fff;
  border-radius: 16px 16px 0 0;
  z-index: 70;
  transform: translateY(110%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}
.drawer.open {
  transform: translateY(0);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 {
  margin: 0;
  font-size: 16px;
}
.drawer-body {
  padding: 12px 14px 24px;
  overflow: auto;
}
.drawer-foot {
  display: flex;
  gap: 8px;
  padding: 10px 14px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
}
.btn {
  flex: 1;
  border-radius: 999px;
  padding: 12px;
  font-weight: 700;
  font-size: 14px;
}
.btn-primary {
  background: #111;
  color: #fff;
}
.btn-outline {
  background: #fff;
  border: 1px solid #111;
  color: #111;
}

/* category popup grid */
.cat-pop-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.cat-pop-item {
  text-align: center;
  padding: 0;
  border-radius: 8px;
  border: 2px solid transparent;
  background: transparent;
}
.cat-pop-item.selected {
  border-color: #111;
}
.cat-pop-item .thumb {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #eee;
  border: 1px solid var(--line);
}
.cat-pop-item .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cat-pop-item .name {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
}
.multi-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 650;
  color: var(--text);
}

.search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafafa;
  margin-bottom: 10px;
}
.lang-list,
.filter-list {
  display: grid;
  gap: 8px;
}
.lang-item,
.filter-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  text-align: left;
  background: #fff;
  font-weight: 600;
}
.lang-item.active,
.filter-item.active {
  border-color: #111;
  background: #f7f7f7;
}
.filter-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 12px;
}

/* ===== Detail ===== */
.detail {
  display: none;
  min-height: 100vh;
  background: #fff;
  padding-bottom: calc(84px + var(--safe-b));
}
.detail.open {
  display: block;
}
.detail-top {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}
.carousel {
  background: #111;
  position: relative;
  touch-action: pan-y;
}
.carousel-stage {
  width: 100%;
  aspect-ratio: 3/4;
  max-height: min(72vh, 860px);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.carousel-stage img,
.carousel-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111;
}
.carousel-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
}
.carousel-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}
.carousel-dots span.on {
  background: #fff;
}
.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
}
.carousel-nav.prev {
  left: 8px;
}
.carousel-nav.next {
  right: 8px;
}
.thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.thumbs button {
  width: 58px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  padding: 0;
  flex: 0 0 auto;
  background: #eee;
}
.thumbs button.on {
  border-color: #111;
}
.thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.detail-info {
  padding: 14px 16px;
  max-width: 720px;
  margin: 0 auto;
}
.detail-code {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.detail-title {
  margin: 6px 0 0;
  font-size: 20px;
  font-weight: 750;
}
.detail-price {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 700;
}
.specs {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.spec-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.spec-row:last-child {
  border-bottom: 0;
}
.spec-row dt {
  margin: 0;
  color: var(--muted);
}
.spec-row dd {
  margin: 0;
  font-weight: 650;
}
.related h3 {
  margin: 18px 0 10px;
  font-size: 15px;
}
.detail-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 10px;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  z-index: 35;
}

/* contact modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.5);
}
.modal.open {
  display: flex;
}
.modal-card {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.modal-card h3 {
  margin: 0 0 6px;
}
.modal-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}
.qr {
  width: 200px;
  height: 200px;
  object-fit: contain;
  margin: 0 auto 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

/* list-only mode hides home rails */
body.mode-list .home-marketing {
  display: none;
}
body.mode-detail .home,
body.mode-detail .list-shell,
body.mode-detail .fab-col {
  display: none;
}
