/* Ajustes solicitados somente para desktop. O mobile permanece inalterado. */
@media (min-width: 769px) {
  body.sd-desktop {
    --sd-chat-popup-backdrop: oklch(0.24 0 0 / 32%);
    --sd-chat-popup-shadow: 0 18px 60px oklch(0.24 0 0 / 22%);
    --sd-panel-surface: oklch(1 0 0);
    --sd-panel-ink: oklch(0.27 0 0);
    --sd-panel-text-size: 14px;
    --sd-panel-title-size: 17px;
  }
  /* Hidden is authoritative, including when an old panel class survives closing. */
  html body.sd-desktop #overlay.hidden,
  html body.sd-desktop #overlay.hidden:is(.sd-profile-overlay, .sd-delivery-overlay, .sd-order-track-detail-active, .sd-ticket-drawer-active, .support-chat-overlay),
  html body.sd-desktop #overlay:empty {
    display: none !important;
    pointer-events: none !important;
  }
  html:has(body.sd-desktop) {
    scrollbar-gutter: stable !important;
    overflow-y: auto !important;
  }
  /* Lock the root scroller rather than propagating body's overflow to it.
     The gutter remains reserved both before and during profile navigation. */
  html:has(body.sd-desktop.sd-panel-open) {
    overflow-y: hidden !important;
  }
  html:has(body.sd-desktop) body.sd-desktop,
  html:has(body.sd-desktop) body.sd-desktop.sd-panel-open {
    scrollbar-gutter: auto !important;
    overflow-x: clip !important;
    overflow-y: visible !important;
  }
  html body.sd-desktop .topbar #profileBtn .sdfood-profile-lottie {
    display: block !important;
    width: 34px !important;
    height: 34px !important;
    flex: 0 0 34px !important;
  }
  html body.sd-desktop .topbar #profileBtn .sdfood-profile-lottie svg {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
  }
  /* Body-child filtering hides appConfirm; its original styles are mobile-only. */
  html body.sd-desktop > .app-confirm {
    position: fixed !important;
    inset: 0 !important;
    z-index: 100000 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100% !important;
    max-width: none !important;
    height: 100dvh;
    margin: 0 !important;
    padding: 24px;
    overflow: auto;
    background: var(--sd-chat-popup-backdrop);
    pointer-events: auto;
  }
  html body.sd-desktop > .app-confirm .app-confirm-box {
    box-sizing: border-box;
    width: min(100%, 360px);
    padding: 20px;
    border-radius: 8px;
    background: var(--sd-panel-surface);
    color: var(--sd-panel-ink);
    box-shadow: var(--sd-chat-popup-shadow);
    font-size: var(--sd-panel-text-size);
    line-height: 1.5;
  }
  html body.sd-desktop > .app-confirm .app-confirm-box p {
    margin: 0 0 20px;
  }
  html body.sd-desktop > .app-confirm .app-confirm-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
  }
  html body.sd-desktop > .app-confirm .app-confirm-actions button {
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--head-border);
    border-radius: 6px;
    background: var(--head-search);
    color: var(--sd-panel-ink);
    font: inherit;
    cursor: pointer;
  }
  html body.sd-desktop > .app-confirm .app-confirm-actions button.danger {
    border-color: var(--head-purple);
    background: var(--head-purple);
    color: var(--sd-panel-surface);
  }
  html body.sd-desktop > .app-confirm .app-confirm-actions button:focus-visible {
    outline: 2px solid var(--head-purple);
    outline-offset: 3px;
  }
  /* One scroll owner and fixed text metrics across profile/status transitions. */
  html body.sd-desktop #overlay:not(.hidden):is(.sd-profile-overlay, .sd-delivery-overlay, .sd-order-track-detail-active) {
    overflow: hidden !important;
  }
  html body.sd-desktop #overlay:not(.hidden):is(.sd-profile-overlay, .sd-delivery-overlay, .sd-order-track-detail-active) > .drawer,
  html body.sd-desktop #overlay.sd-desktop-panel:not(.hidden):is(.sd-profile-overlay, .sd-delivery-overlay, .sd-order-track-detail-active) > .drawer.sd-drawer-lateral {
    box-sizing: border-box !important;
    width: min(420px, 100%) !important;
    min-width: 0 !important;
    max-width: 420px !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 100dvh !important;
    min-height: 0 !important;
    max-height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: none;
    background: var(--sd-panel-surface) !important;
    color: var(--sd-panel-ink) !important;
    font-size: var(--sd-panel-text-size) !important;
  }
  html body.sd-desktop #overlay:not(.hidden):is(.sd-profile-overlay, .sd-delivery-overlay, .sd-order-track-detail-active) > .drawer::-webkit-scrollbar {
    display: none;
  }
  html body.sd-desktop #overlay .drawer :is(.sd-profile-screen, .sd-subpage, .sd-delivery-code-screen, .sd-notif-body) {
    min-width: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    font-size: var(--sd-panel-text-size) !important;
  }
  html body.sd-desktop #overlay.sd-profile-overlay .sd-status-page :is(.sd-track-order, .sd-track-order *, .sd-notif-body) {
    font-size: var(--sd-panel-text-size) !important;
  }
  html body.sd-desktop #overlay .drawer .sd-subhead-text {
    font-size: var(--sd-panel-title-size) !important;
  }
  /* Acompanhar pedido: visual sem bordas e sem botão de voltar. */
  html body.sd-desktop #overlay.sd-order-track-detail-active > .drawer.sd-order-track-detail-drawer,
  html body.sd-desktop #overlay.sd-order-track-detail-active .sd-order-track-detail-screen,
  html body.sd-desktop #overlay.sd-order-track-detail-active .sd-order-track-status-card,
  html body.sd-desktop #overlay.sd-order-track-detail-active .sd-order-track-store-avatar,
  html body.sd-desktop #overlay.sd-order-track-detail-active .sd-order-track-store-row,
  html body.sd-desktop #overlay.sd-order-track-detail-active .sd-order-track-item-row,
  html body.sd-desktop #overlay.sd-order-track-detail-active .sd-order-track-order-summary,
  html body.sd-desktop #overlay.sd-order-track-detail-active .sd-order-track-payment-row,
  html body.sd-desktop #overlay.sd-order-track-detail-active .sd-order-track-code-row,
  html body.sd-desktop #overlay.sd-order-track-detail-active .sd-order-track-cancel {
    border: 0 !important;
    border-top: 0 !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
  }
  html body.sd-desktop #overlay.sd-order-track-detail-active .sd-order-track-back {
    display: none !important;
  }
  html body.sd-desktop #overlay.sd-order-track-detail-active .sd-order-track-topbar {
    justify-content: flex-end !important;
  }
  html body.sd-desktop #overlay .drawer .sd-order-track-detail-screen .sd-order-track-items,
  html body.sd-desktop #overlay .drawer .sd-order-track-detail-screen .sd-order-track-items > li.sd-order-track-item-row {
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  /* Chat de ajuda: popup independente, centralizado e com rolagem só nas mensagens. */
  html body.sd-desktop #overlay.support-chat-overlay:not(.hidden) {
    position: fixed !important;
    inset: 0 !important;
    z-index: 4001 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100vw !important;
    height: 100dvh !important;
    padding: 24px !important;
    overflow: hidden !important;
    background: var(--sd-chat-popup-backdrop) !important;
  }
  html body.sd-desktop #overlay.support-chat-overlay > .drawer {
    display: flex !important;
    position: relative !important;
    flex: 0 0 min(420px, calc(100vw - 48px)) !important;
    width: min(420px, calc(100vw - 48px)) !important;
    min-width: 0 !important;
    max-width: 420px !important;
    height: min(560px, calc(100dvh - 48px)) !important;
    min-height: 0 !important;
    max-height: calc(100dvh - 48px) !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: var(--sd-panel-surface) !important;
    box-shadow: var(--sd-chat-popup-shadow) !important;
  }
  html body.sd-desktop #overlay.support-chat-overlay > .drawer,
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-shell,
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-header,
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-messages,
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-quick-replies,
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-compose-wrap,
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-compose-form {
    box-sizing: border-box !important;
  }
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-shell {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    border-radius: 8px !important;
  }
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-messages {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  html body.sd-desktop #overlay.support-chat-overlay :is(.support-chat-header, .support-chat-quick-replies, .support-chat-compose-wrap) {
    flex: 0 0 auto !important;
  }
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-compose-wrap,
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-compose-form {
    max-width: 100% !important;
  }
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-send-btn {
    flex: 0 0 44px !important;
    width: 44px !important;
    min-width: 44px !important;
  }

  /* Código de entrega: caracteres mais compactos, sem alterar ações. */
  /* Filters keep identical text metrics; only the color indicates selection. */
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer #deliveryCodeOrderFilters > .sd-hist-tab,
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer #deliveryCodeOrderFilters > .sd-hist-tab.is-active,
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer #deliveryCodeOrderFilters > .sd-hist-tab[aria-selected="true"],
  html body.sd-desktop #overlay.sd-profile-overlay .profile-page.sd-hist-page > .sd-hist-tabs > .sd-hist-tab,
  html body.sd-desktop #overlay.sd-profile-overlay .profile-page.sd-hist-page > .sd-hist-tabs > .sd-hist-tab.is-active,
  html body.sd-desktop #overlay.sd-profile-overlay .profile-page.sd-hist-page > .sd-hist-tabs > .sd-hist-tab[aria-selected="true"] {
    font-family: "Inter", sans-serif !important;
    font-size: var(--sd-panel-text-size) !important;
    font-weight: 400 !important;
    line-height: 1.2 !important;
    letter-spacing: 0 !important;
    transform: none !important;
    transition: none !important;
  }
  /* The drawer owns scrolling, not the list inserted again on every click. */
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer .sd-delivery-code-body,
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer .sd-delivery-orders,
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer #deliveryCodeOrdersList,
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer #deliveryCodeOrdersList .sd-delivery-orders-list {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    animation: none !important;
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer,
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer * {
    scrollbar-width: none !important;
  }
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer::-webkit-scrollbar,
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer *::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }
  html body.sd-desktop #overlay.sd-delivery-overlay > .drawer.sd-delivery-drawer #deliveryCodeOrdersList :is(strong, span, small) {
    font-size: var(--sd-panel-text-size) !important;
    animation: none !important;
    transition: none !important;
  }
  html body.sd-desktop #overlay.sd-delivery-overlay .sd-delivery-code-screen .sd-delivery-code-box {
    box-sizing: border-box !important;
    width: min(100%, 260px) !important;
    min-width: 0 !important;
    min-height: 52px !important;
    padding: 8px 12px !important;
    margin-right: auto !important;
    margin-left: auto !important;
  }
  html body.sd-desktop #overlay.sd-delivery-overlay .sd-delivery-code-screen .sd-delivery-code-digits {
    flex: 0 1 auto !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
  }
  html body.sd-desktop #overlay.sd-delivery-overlay .sd-delivery-code-screen .sd-delivery-code-digit {
    flex: 0 0 23px !important;
    width: 23px !important;
    min-width: 23px !important;
    height: 30px !important;
    font-size: 12px !important;
    letter-spacing: 0 !important;
  }
  html body.sd-desktop #overlay.sd-delivery-overlay .sd-delivery-code-screen .sd-delivery-code-copy {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    width: auto !important;
    min-width: 0 !important;
    height: 30px !important;
    margin-left: 6px !important;
    padding: 0 10px !important;
  }
  html body.sd-desktop #overlay.sd-delivery-overlay .sd-delivery-code-screen .sd-delivery-code-copy::after {
    content: "Copiar" !important;
    display: inline !important;
  }
}

/* Página exclusiva de chat: nunca mostra a loja, nem depende da aba de origem. */
html.sd-chat-tab body > :not(#overlay) {
  display: none !important;
}
html.sd-chat-tab,
html.sd-chat-tab body {
  height: 100% !important;
  margin: 0 !important;
  overflow: hidden !important;
}
html.sd-chat-tab body #overlay:not(.hidden) {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100dvh !important;
  padding: 0 !important;
  display: flex !important;
  align-items: stretch !important;
  justify-content: center !important;
  background: var(--sd-profile-surface, Canvas) !important;
}
html.sd-chat-tab body #overlay:not(.hidden) > .drawer,
html.sd-chat-tab body #overlay.support-chat-overlay .support-chat-shell {
  position: static !important;
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: 100% !important;
  max-height: 100% !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: hidden !important;
}
html.sd-chat-tab body #overlay.support-chat-overlay .support-chat-messages {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}
html.sd-chat-tab body #overlay.support-chat-overlay :is(.support-chat-header, .support-chat-quick-replies, .support-chat-compose-wrap) {
  flex: 0 0 auto !important;
}
/* Correções pontuais: Histórico, resultado PIX e largura das mensagens.
   Exclusivas do desktop; nenhum estilo ou script mobile foi alterado. */
@media (min-width: 769px) {
  html body.sd-desktop {
    --sd-pix-surface: oklch(1 0 0);
    --sd-pix-code-surface: oklch(0.97 0.005 300);
    --sd-pix-ink: oklch(0.27 0 0);
    --sd-pix-muted: oklch(0.55 0 0);
    --sd-pix-border: oklch(0.89 0 0);
    --sd-pix-primary: var(--head-purple, #000000);
  }

  /* Remover só a moldura externa; manter bordas dos pedidos e das abas. */
  html body.sd-desktop #overlay.sd-profile-overlay .profile-page.sd-hist-page > #profileOrdersList > .sd-hist-list,
  html body.sd-desktop #overlay.sd-profile-overlay .profile-page.sd-hist-page > #profileOrdersList > .sd-hist-empty {
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
  }

  html body.sd-desktop #overlay.sd-profile-overlay #walletPixResult {
    min-width: 0;
    font: inherit;
  }
  html body.sd-desktop #overlay.sd-profile-overlay #walletPixResult .deposit-pix-card {
    display: block !important;
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    margin-top: 16px !important;
    padding: 16px !important;
    border: 1px solid var(--sd-pix-border);
    border-radius: 8px !important;
    background: var(--sd-pix-surface);
    color: var(--sd-pix-ink);
    font: 400 14px/1.5 "Inter", sans-serif !important;
    text-align: left !important;
  }
  html body.sd-desktop #overlay.sd-profile-overlay #walletPixResult .deposit-pix-label {
    display: block;
    font-weight: 600;
    color: var(--sd-pix-ink);
  }
  html body.sd-desktop #overlay.sd-profile-overlay #walletPixResult .deposit-pix-card img {
    display: block !important;
    flex: none !important;
    width: min(300px, 100%) !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: contain !important;
    margin: 20px auto !important;
    padding: 0 !important;
    background: var(--sd-pix-surface) !important;
    border-radius: 0 !important;
  }
  html body.sd-desktop #overlay.sd-profile-overlay #walletPixResult .deposit-pix-card > small {
    box-sizing: border-box !important;
    display: block !important;
    max-width: 100% !important;
    padding: 12px !important;
    border-radius: 6px !important;
    background: var(--sd-pix-code-surface) !important;
    color: var(--sd-pix-ink) !important;
    font: 400 13px/1.5 "Inter", sans-serif !important;
    text-align: left !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: anywhere !important;
    user-select: text;
  }
  html body.sd-desktop #overlay.sd-profile-overlay #walletPixResult .deposit-copy {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    width: 100% !important;
    min-height: 44px !important;
    margin-top: 14px !important;
    padding: 10px 14px !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: var(--sd-pix-primary) !important;
    color: var(--sd-pix-surface) !important;
    font: 600 14px/1.4 "Inter", sans-serif !important;
    white-space: normal !important;
    cursor: pointer;
  }
  html body.sd-desktop #overlay.sd-profile-overlay #walletPixResult .deposit-copy:focus-visible {
    outline: 2px solid var(--sd-pix-primary);
    outline-offset: 3px;
  }
  html body.sd-desktop #overlay.sd-profile-overlay #walletPixResult .upload-note {
    color: var(--sd-pix-muted);
    font: 400 13px/1.5 "Inter", sans-serif;
    overflow-wrap: break-word;
  }

  /* O limite percentual deve usar a largura da conversa, não uma linha
     já encolhida pelo próprio texto. Preservar palavras e quebras enviadas. */
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-row {
    box-sizing: border-box !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-bubble-wrap {
    box-sizing: border-box !important;
    flex: 0 1 auto !important;
    width: fit-content !important;
    min-width: 0 !important;
    max-width: 78% !important;
  }
  html body.sd-desktop #overlay.support-chat-overlay .support-chat-bubble {
    box-sizing: border-box !important;
    flex: 0 0 auto !important;
    width: fit-content !important;
    min-width: 0 !important;
    max-width: 100% !important;
    white-space: pre-wrap !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    hyphens: none !important;
    text-overflow: clip !important;
  }

  /* Perfil: manter a largura normal do painel e os cartões compactos. */
  html body.sd-desktop #overlay.sd-profile-overlay .sd-profile-screen .sd-profile-summary {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
    width: 100% !important;
    min-height: 96px !important;
    margin: 16px 0 20px !important;
    padding: 0 !important;
  }
  html body.sd-desktop #overlay.sd-profile-overlay .sd-profile-screen .sd-profile-summary-divider {
    display: none !important;
  }
  html body.sd-desktop #overlay.sd-profile-overlay .sd-profile-screen .sd-profile-summary-card {
    box-sizing: border-box !important;
    display: grid !important;
    grid-template-columns: 42px minmax(0, 1fr) 8px !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 96px !important;
    height: auto !important;
    padding: 12px 10px !important;
  }
  html body.sd-desktop #overlay.sd-profile-overlay .sd-profile-screen .sd-profile-summary-copy {
    width: 100% !important;
    min-width: 0 !important;
    gap: 5px !important;
  }
  html body.sd-desktop #overlay.sd-profile-overlay .sd-profile-screen .sd-profile-summary-copy > :is(span, strong, small) {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    text-overflow: clip !important;
    line-height: 1.35 !important;
  }
  html body.sd-desktop #overlay.sd-profile-overlay .sd-profile-screen .sd-profile-summary-copy > :is(span, strong) {
    font-size: 15px !important;
  }
}
