.shop-navigation-enabled {
  --shop-tabbar-height: 64px;
  --shop-tabbar-total: calc(var(--shop-tabbar-height) + env(safe-area-inset-bottom,0px));
  padding-bottom: var(--shop-tabbar-total);
}

.shop-tabbar {
  position: fixed;
  inset: auto 0 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  width: min(100%,560px);
  margin-inline: auto;
  padding: 4px 8px calc(3px + env(safe-area-inset-bottom,0px));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: var(--white);
  box-shadow: 0 -8px 28px rgba(121,26,52,.08);
}

.shop-tabbar-entry {
  display: grid;
  min-height: 56px;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 3px 4px;
  border: none;
  border-radius: 11px;
  background: none;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.2;
  text-align: center;
}

.shop-tabbar-entry:hover {
  background: var(--page);
  color: var(--accent);
}

.shop-tabbar-entry[aria-current="page"],
.shop-tabbar-entry[aria-expanded="true"] {
  color: var(--accent);
  font-weight: 750;
}

.shop-tabbar-entry:focus-visible {
  outline-offset: -2px;
}

.shop-tab-icon {
  display: inline-grid;
  position: relative;
  width: 25px;
  height: 25px;
  place-items: center;
  flex: none;
}

.shop-tab-icon svg {
  display: block;
  width: 24px;
  height: 24px;
}

.shop-tab-badge {
  position: absolute;
  top: -4px;
  left: calc(100% - 8px);
  min-width: 17px;
  padding: 2px 4px;
  border-radius: 100px;
  background: var(--accent);
  color: var(--white);
  font-size: .66rem;
  font-weight: 700;
  line-height: 1.18;
  white-space: nowrap;
}

.shop-messages-active {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.shop-messages-active > .site-header {
  flex: none;
}

.shop-messages-active > #main {
  display: flex;
  flex: 1;
  min-height: 220px;
}

.shop-messages-active > .site-footer {
  display: none;
}

.shop-messages {
  display: flex;
  width: min(100%,820px);
  margin-inline: auto;
  padding-block: 12px;
}

.shop-message-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.shop-message-empty h1 {
  font-size: 1.15rem;
}

.shop-message-empty p {
  margin-block: 6px 12px;
  color: var(--muted);
}

.shop-chat {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
}

.shop-chat-header {
  display: grid;
  flex: none;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}

.shop-chat-header h1 {
  font-size: 1.08rem;
}

.shop-chat-header > .shop-tab-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--tint);
  color: var(--accent);
}

.shop-chat-refresh {
  min-height: 42px;
  padding: 6px 10px;
  border-color: transparent;
  font-size: .88rem;
}

.shop-chat-feed {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px;
  background: var(--page);
}

.shop-chat-feed:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.shop-chat-empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
}

.shop-chat-message {
  display: grid;
  flex: none;
  min-width: 0;
  max-width: min(85%,510px);
  align-self: flex-start;
  justify-items: start;
  gap: 4px;
}

.shop-chat-from-customer {
  align-self: flex-end;
  justify-items: end;
}

.shop-chat-sender,.shop-chat-timestamp {
  color: var(--muted);
  font-size: .78rem;
}

.shop-chat-bubble {
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px 13px 13px;
  background: var(--white);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.shop-chat-from-customer .shop-chat-bubble {
  border-color: rgba(182,25,46,.13);
  border-radius: 13px 4px 13px 13px;
  background: rgba(182,25,46,.10);
  color: var(--ink);
}

.shop-chat-form {
  flex: none;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}

.shop-chat-composer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--page);
}

.shop-chat-composer:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px var(--tint);
}

.shop-chat-composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 11px 10px;
  border: 0;
  background: transparent;
  line-height: 1.35;
  outline: none;
  box-shadow: none;
  resize: none;
}

.shop-chat-composer textarea:focus-visible {
  outline: none;
}

.shop-chat-composer textarea::placeholder {
  color: var(--muted);
}

.shop-chat-submit {
  flex: none;
  gap: 5px;
  min-height: 44px;
  padding-inline: 11px;
  border-radius: 13px;
  font-size: .875rem;
}

.shop-chat-submit .shop-tab-icon,
.shop-chat-submit .shop-tab-icon svg {
  width: 16px;
  height: 16px;
}

.shop-chat-submit:disabled {
  border-color: transparent;
  background: #f4e7ea;
  color: var(--muted);
  opacity: 1;
}

.shop-chat-notice {
  flex: none;
  padding: 7px 16px;
  color: var(--alert);
  font-size: .88rem;
}

@media (min-width:761px) {
  html {
    scroll-padding-top: 83px;
  }

  .shop-navigation-enabled {
    padding-bottom: 0;
  }

  .shop-navigation-enabled > .site-header {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .shop-navigation-enabled .top-actions {
    display: none;
  }

  .shop-tabbar {
    position: static;
    display: flex;
    gap: 5px;
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .shop-tabbar-entry {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 44px;
    padding: 6px 13px;
    font-size: .9rem;
    white-space: nowrap;
  }

  .shop-tabbar .shop-tab-icon,
  .shop-tabbar .shop-tab-icon svg {
    width: 20px;
    height: 20px;
  }

  .shop-tabbar .shop-tab-badge {
    top: -7px;
    right: -5px;
    left: auto;
  }
}

@media (max-width:760px) {
  .shop-navigation-enabled {
    --shop-tabbar-height: 64px;
  }
  .shop-tabbar {
    width: 100%;
    padding-inline: max(8px,env(safe-area-inset-left,0px)) max(8px,env(safe-area-inset-right,0px));
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
  .shop-navigation-enabled .mobile-buy {
    bottom: var(--shop-tabbar-total);
    padding-bottom: 8px;
  }
  .shop-navigation-enabled.has-mobile-buy .site-footer {
    padding-bottom: 65px;
  }
  .shop-navigation-enabled .top-actions #customer-nav,
  .shop-navigation-enabled .top-actions #cart-open {
    display: none;
  }
  .shop-messages {
    padding-block: 6px 8px;
  }
  .shop-chat-header,.shop-chat-feed,.shop-chat-form,.shop-chat-notice {
    padding-inline: 11px;
  }
  .shop-chat-message {
    max-width: 91%;
  }
}
