/* RC-scoped final cascade: layout changes only, media elements remain mounted by app.js. */
.feed-list .video-card,
.post-page .video-card,
.profile-page .video-card {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0 !important;
  align-items: stretch !important;
}

.video-card > .video-creator-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(216, 166, 64, 0.2);
  background: #050505;
}

.video-creator-header .creator-identity {
  min-width: 0;
  margin: 0 !important;
}

.video-creator-header .creator-identity span {
  min-width: 0;
}

.video-creator-header .creator-identity strong,
.video-creator-header .creator-identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-creator-header .post-timestamp {
  flex: 0 1 auto;
  margin: 0;
  text-align: right;
}

.video-card > .embed-shell,
.video-card > .shared-profile-preview,
.video-card > .shared-product-preview {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  border-inline: 0 !important;
}

.video-card > .video-engagement-actions {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  margin: 0 !important;
  padding: 10px 14px !important;
  border-top: 1px solid rgba(216, 166, 64, 0.18);
  border-bottom: 1px solid rgba(216, 166, 64, 0.18);
  background: #050505;
}

.video-card > .video-details {
  display: flex !important;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 16px !important;
}

.video-details > .comment-box {
  order: 99;
  margin-top: 4px;
}

.engagement-count-button[hidden] {
  display: none !important;
}

.product-association-disclosure {
  margin: 8px 0 0;
  color: #d8cfba;
  font-size: 0.82rem;
  line-height: 1.45;
}

.responsive-product-picture {
  display: block;
  width: 100%;
  height: 100%;
}

.responsive-product-picture > img {
  display: block;
  width: 100%;
  height: 100%;
}

.product-gallery-stage > picture {
  display: block;
  width: 100%;
  height: 100%;
}

.product-gallery-stage > picture > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

#profileMediaViewerModal,
#profileMediaViewerModal .profile-media-viewer {
  overscroll-behavior: contain !important;
}

#profileMediaViewerModal .profile-media-viewer {
  touch-action: none !important;
}

#profileMediaViewerModal .profile-media-viewer img {
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-drag: none !important;
  transform-origin: center center !important;
  will-change: transform;
}

@media (max-width: 720px) {
  .video-card > .video-creator-header {
    align-items: flex-start;
    padding: 12px;
  }

  .video-creator-header .post-timestamp {
    max-width: 44%;
    font-size: 0.72rem;
  }

  .video-card > .video-engagement-actions {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding-inline: 10px !important;
  }

  .video-card > .video-details {
    padding: 14px 12px !important;
  }
}

/* Messaging and viewport stability pass. This file loads last so legacy RC
   overrides cannot expand the conversation outside its responsive column. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.workspace,
.content-grid,
.feed-column,
.insight-column,
.chat-shell,
.chat-list,
.chat-thread,
.chat-messages,
.chat-composer,
.chat-bubble {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.content-grid > *,
.insight-column > * {
  min-width: 0;
}

.chat-shell {
  width: 100% !important;
  overflow: hidden !important;
  contain: inline-size;
}

.chat-list,
.chat-thread {
  overflow: hidden !important;
}

.chat-list {
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

.chat-thread {
  width: 100%;
}

.chat-head,
.chat-person,
.chat-person-identity {
  min-width: 0;
  max-width: 100%;
}

.chat-messages {
  width: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior-x: none;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.chat-bubble {
  overflow-wrap: anywhere;
  word-break: break-word;
  transform: none !important;
}

.chat-bubble img,
.chat-bubble video {
  max-width: 100%;
}

.chat-composer {
  position: relative;
  display: grid !important;
  grid-template-columns: 58px 46px minmax(0, 1fr) auto !important;
  grid-template-areas:
    "preview preview preview preview"
    "image add body send";
  align-items: center !important;
  gap: 10px !important;
  width: 100% !important;
  overflow: hidden !important;
  padding: 12px !important;
}

.message-image-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.message-image-picker,
.message-image-add-more,
.chat-composer > input[name="body"],
.chat-composer > .action-button {
  box-sizing: border-box !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  margin: 0 !important;
  flex: none !important;
}

.message-image-picker {
  grid-area: image;
  display: grid !important;
  place-items: center;
  width: 58px !important;
  min-width: 58px !important;
  padding: 0 !important;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--gold-bright);
  background: rgba(216, 166, 64, 0.08);
  cursor: pointer;
}

.message-image-add-more {
  grid-area: add;
  display: grid;
  place-items: center;
  width: 46px !important;
  min-width: 46px !important;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--gold-bright);
  background: rgba(216, 166, 64, 0.08);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.chat-composer > input[name="body"] {
  grid-area: body;
  width: 100% !important;
  min-width: 0 !important;
}

.chat-composer > .action-button {
  grid-area: send;
  width: auto !important;
  min-width: 64px !important;
  padding: 0 14px !important;
  border-radius: 999px !important;
}

.chat-composer .message-image-preview:not([hidden]) {
  grid-area: preview;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 92px !important;
  height: 92px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  padding: 16px 14px 10px !important;
  scroll-snap-type: x proximity;
  overscroll-behavior-inline: contain;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}

.message-candidate-rail {
  max-width: 100%;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  overscroll-behavior-inline: contain;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}

.message-image-preview-item {
  flex: 0 0 64px !important;
  width: 64px !important;
  height: 64px !important;
  max-width: 64px !important;
  overflow: visible !important;
  scroll-snap-align: start;
}

.message-image-preview-item > button[data-remove-message-image] {
  top: -8px !important;
  right: -8px !important;
  z-index: 100 !important;
}

.send-to-group-form > .action-button {
  justify-self: start;
  position: sticky;
  bottom: 0;
  z-index: 2;
  width: min(280px, 100%) !important;
  min-width: 220px;
  max-width: 100% !important;
  min-height: 48px;
  margin: 10px 0 4px !important;
  padding-inline: 20px !important;
  box-shadow: 0 -8px 18px rgba(5, 5, 5, 0.72);
}

.send-to-group-form {
  min-width: 0;
  max-height: min(250px, 34dvh) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.send-to-toolbar,
.send-to-footer {
  gap: 12px !important;
}

.post-edit-catalog-picker {
  min-width: 0;
}

.post-edit-catalog-picker select {
  color: var(--gold) !important;
  border-color: rgba(221, 173, 66, 0.58) !important;
  background: #080705 !important;
  cursor: pointer;
}

.post-edit-catalog-picker select option {
  color: #f5d982;
  background: #080705;
}

.send-to-footer {
  position: relative;
  z-index: 3;
  min-height: 54px;
  flex: 0 0 auto;
  align-items: center !important;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.send-to-toolbar .action-button,
.send-to-footer .action-button {
  width: auto !important;
  max-width: 100%;
  flex: 0 0 auto;
}

/* Profile URLs stay in fixed geometry, with the supplied artwork unchanged. */
.profile-social-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 12px;
  width: fit-content;
  max-width: 100%;
  min-height: 48px;
  margin: 12px 0;
}

.profile-social-link {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  padding: 7px;
  border: 1px solid rgba(216, 166, 64, 0.22);
  border-radius: 8px;
  background: transparent;
  transition: opacity 200ms ease, filter 200ms ease, border-color 200ms ease;
}

.profile-social-link img {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
  object-position: center;
}

.profile-social-link.is-connected {
  opacity: 1;
  filter: drop-shadow(0 0 8px rgba(242, 205, 118, 0.42));
}

.profile-social-link.is-connected:hover,
.profile-social-link.is-connected:focus-visible {
  border-color: rgba(242, 205, 118, 0.68);
  filter: drop-shadow(0 0 11px rgba(242, 205, 118, 0.58));
}

.profile-social-link.is-disconnected {
  opacity: 0.48;
  pointer-events: none;
  cursor: default;
  filter: none;
}

.profile-external-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.profile-external-link {
  display: block;
  max-width: min(100%, 260px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-social-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.profile-social-fields label,
.profile-social-fields input {
  min-width: 0;
  max-width: 100%;
}

/* Adjacent Feed surfaces use the same canonical platform black. */
.video-card,
.video-card > .video-creator-header,
.video-card > .video-engagement-actions,
.video-card > .video-details {
  background-color: var(--bg) !important;
}

.engagement-count-button[hidden],
[data-content-share-count][hidden] {
  display: none !important;
}

.product-media-provenance {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  margin: 6px 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

/* Product media is inspection-first on every viewport. */
.product-media,
.product-panel-media,
.instrument-product-media,
.cart-product-media,
.shared-product-preview,
.product-panel-gallery-trigger,
.responsive-product-picture {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  background: #000;
}

.product-media img,
.product-panel-media img,
.instrument-product-media img,
.cart-product-media img,
.shared-product-preview img,
.product-panel-gallery-trigger img,
.responsive-product-picture > img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  object-fit: contain !important;
  object-position: center !important;
}

#productGalleryModal,
#productGalleryModal .product-gallery-viewer,
#productGalleryModal .product-gallery-stage {
  overscroll-behavior: contain !important;
}

#productGalleryModal .product-gallery-stage,
#productGalleryModal #productGalleryImage {
  touch-action: none !important;
}

#productGalleryModal #productGalleryImage {
  user-select: none !important;
  -webkit-user-drag: none !important;
  transform-origin: center center !important;
  will-change: transform;
}

.modal-backdrop:not(.is-hidden) {
  overscroll-behavior: none !important;
}

.modal-backdrop:not(.is-hidden) > [role="dialog"] {
  overscroll-behavior: contain !important;
}

/* Keep desktop context and tablet navigation available during long Feed sessions. */
@media (min-width: 861px) {
  html,
  body {
    overflow-x: clip !important;
  }

  body {
    overflow-y: visible !important;
  }
}

@media (min-width: 1181px) {
  .app-shell {
    align-items: start;
    overflow: visible !important;
  }

  .sidebar {
    position: sticky !important;
    top: 0 !important;
    align-self: start !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: none !important;
    -ms-overflow-style: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  .insight-column {
    position: sticky !important;
    top: 18px !important;
    align-self: start !important;
    max-height: calc(100dvh - 36px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: none !important;
    -ms-overflow-style: none;
  }

  .insight-column::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  .cart-summary {
    position: sticky !important;
    top: 20px !important;
    align-self: start !important;
  }
}

@media (min-width: 861px) and (max-width: 1180px) {
  .pinned-brand {
    display: grid !important;
  }

  .cart-summary {
    position: sticky !important;
    top: 76px !important;
    align-self: start !important;
  }
}

/* Editing surfaces are portals, not viewport-scale transitions. */
.modal-backdrop:not(#storyViewerModal):not(#callModal) > .upload-modal,
.modal-backdrop:not(#storyViewerModal):not(#callModal) > .product-gallery-viewer,
.modal-backdrop:not(#storyViewerModal):not(#callModal) > .profile-media-viewer {
  animation: none !important;
  max-width: calc(100% - 24px) !important;
  box-sizing: border-box !important;
}

@media (max-width: 860px) {
  .modal-backdrop input,
  .modal-backdrop textarea,
  .modal-backdrop select,
  .chat-composer input {
    font-size: 16px !important;
  }

  .profile-social-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .chat-composer {
    grid-template-columns: 52px 44px minmax(0, 1fr) 62px !important;
    gap: 7px !important;
    padding: 9px !important;
  }

  .message-image-picker {
    width: 52px !important;
    min-width: 52px !important;
    font-size: 0.82rem;
  }

  .message-image-add-more {
    width: 44px !important;
    min-width: 44px !important;
  }

  .chat-composer > .action-button {
    width: 62px !important;
    min-width: 62px !important;
    padding-inline: 8px !important;
  }

  .send-to-toolbar,
  .send-to-footer {
    align-items: flex-start;
  }

  .send-to-toolbar .action-button,
  .send-to-footer .action-button,
  .send-to-group-form > .action-button {
    min-height: 44px;
    padding-inline: 14px !important;
  }

  .send-to-group-form > .action-button {
    width: min(260px, 100%) !important;
    min-width: 210px;
  }

  .profile-social-row {
    gap: 9px;
  }
}

/* Apply the owner-supplied borderless texture only to controls already rendered solid gold. */
.action-button:not(.secondary):not(.danger):not(.checkout-disabled):not(:disabled) {
  color: #120c02 !important;
  border-color: transparent !important;
  background-color: #dca72c !important;
  background-image: url("./assets/ui-actions/button-texture.png") !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: 100% 100% !important;
  text-shadow: 0 1px 0 rgba(255, 245, 190, 0.34);
}

/* Product bubbles retain their established geometry with the same full texture and a light fade. */
.product-bubble {
  max-width: 100% !important;
  color: #fff1bd !important;
  border-color: transparent !important;
  background-color: #dca72c !important;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.18)),
    url("./assets/ui-actions/button-texture.png") !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: 100% 100% !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.62);
}

.product-bubble:hover,
.product-bubble:focus-visible {
  color: #fff8dc !important;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.12)),
    url("./assets/ui-actions/button-texture.png") !important;
}

#callModal video::-webkit-media-controls-overlay-enclosure,
#callModal video::-webkit-media-controls-timeline-container,
#callModal video::-webkit-media-controls-current-time-display,
#callModal video::-webkit-media-controls-time-remaining-display {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Canvas-backed local preview prevents iOS 15 from painting native pause controls over the camera. */
#callModal .local-call-preview {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: min(210px, 32vw);
  max-height: 34%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid rgba(216, 166, 64, 0.42);
  border-radius: 8px;
  background: #050608;
  box-shadow: var(--shadow);
  z-index: 4;
  pointer-events: none;
}

#callModal .local-call-preview canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#callModal #localCallVideo {
  position: absolute !important;
  inset: 0 auto auto 0 !important;
  width: 1px !important;
  height: 1px !important;
  max-height: none !important;
  opacity: 0 !important;
  clip-path: inset(50%) !important;
  pointer-events: none !important;
}

@media (max-width: 720px) {
  #callModal .local-call-preview {
    right: 8px;
    bottom: 8px;
    width: min(150px, 36vw);
    max-height: 30%;
  }

  .chat-list {
    display: flex !important;
    align-items: stretch;
    gap: 8px !important;
    max-height: 92px !important;
    min-height: 82px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
  }

  .chat-list .chat-person {
    flex: 0 0 220px;
    min-width: 220px !important;
  }

  .message-candidate-rail,
  .chat-composer .message-image-preview:not([hidden]) {
    touch-action: pan-x !important;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 420px) {
  .chat-composer {
    grid-template-columns: 48px 42px minmax(0, 1fr) 58px !important;
    gap: 6px !important;
  }

  .message-image-picker {
    width: 48px !important;
    min-width: 48px !important;
  }

  .message-image-add-more {
    width: 42px !important;
    min-width: 42px !important;
  }

  .chat-composer > .action-button {
    width: 58px !important;
    min-width: 58px !important;
  }

  .send-to-toolbar {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .send-to-toolbar .action-button {
    width: 100% !important;
    white-space: normal;
  }
}
