/* Media cards share a footer. Options never float over a preview or player. */
body.vobixConversation .messageRow .messageBubble.mediaMessage,
body.vobixConversation .messageRow.theirs .messageBubble.mediaMessage.hasMessageMenu {
  width: min(360px, 90%);
  max-width: min(360px, 90%);
  min-width: 0;
  padding: 6px;
  border-radius: 18px;
  white-space: normal;
}
body.vobixConversation .messageRow .mediaMessage .mediaMessageFooter {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding: 2px 2px 0;
}
body.vobixConversation .mediaMessage .mediaMessageInfo {
  display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: center;
  gap: 4px 8px; min-width: 0;
}
body.vobixConversation .mediaMessage .mediaMessageInfo .chatAttachmentMeta { margin: 0; font-size: 11px; }
body.vobixConversation .mediaMessage .messageMeta {
  flex: 1 1 auto; margin: 0; gap: 4px; padding-inline: 3px;
}
body.vobixConversation .mediaMessage .messageMeta .messageTime { font-size: 11px; }
body.vobixConversation .messageRow .mediaMessage .mediaMessageFooter > :is(.messageMenuButton,.chatAttachmentDownload) {
  position: static;
  inset: auto;
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  font-size: 23px;
  line-height: 1;
  touch-action: manipulation;
}
body.vobixConversation .messageRow .mediaMessage .messageActions.mobileOpen {
  top: auto; bottom: 50px; left: auto; right: 4px;
  width: min(270px, calc(100% - 8px)); max-height: min(320px, 50dvh);
}
body.vobixConversation .messageRow .messageBubble.voiceMessage {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 48px;
  column-gap: 10px;
  row-gap: 0;
  padding: 10px 10px 4px;
  align-items: center;
}
body.vobixConversation .voiceMessage .voicePlayButton {
  grid-column: 1; grid-row: 1 / 3;
  width: 44px; height: 44px; min-width: 44px; font-size: 18px;
}
body.vobixConversation .voiceMessage .voiceProgressArea {
  grid-column: 2; grid-row: 1;
  min-width: 0; height: 32px; padding-inline: 6px;
}
body.vobixConversation .voiceMessage .voiceProgressTrack { background: #90bfd9; }
body.vobixConversation .voiceMessage .voiceTime {
  grid-column: 2; grid-row: 2;
  min-width: 0; padding: 0 4px 4px;
  font-size: 11px; line-height: 1.3; text-align: left;
  white-space: nowrap; word-break: normal; font-variant-numeric: tabular-nums;
}
body.vobixConversation .voiceMessage .voiceSpeedButton {
  grid-column: 3; grid-row: 1 / 3;
  width: 48px; min-width: 48px; height: 44px; padding: 0;
  font-size: 13px; line-height: 1; white-space: nowrap;
  border-radius: 22px; touch-action: manipulation;
}
body.vobixConversation .voiceMessage .mediaMessageFooter { grid-row: 3; }
body.vobixConversation .voiceMessage > .viewOnceSenderBadge { grid-column: 1 / -1; grid-row: 4; }
body.vobixConversation .mediaMessage :is(.chatMediaButton,.chatVideoThumbnail) {
  width: 100%; max-width: none; min-width: 0; border-radius: 13px;
}
body.vobixConversation .mediaMessage .chatMediaImage {
  width: 100%; max-height: 360px; min-height: 100px;
  border-radius: 13px; object-fit: contain; background: #e8f4fc;
}
body.vobixConversation .mediaMessage .chatVideoThumbnail {
  width: min(100%, var(--media-preview-width, 360px));
  aspect-ratio: var(--media-ratio, 4 / 3); max-height: 360px; background: #081b2e;
}
body.vobixConversation .mediaMessage .chatVideoThumbnail .chatMediaVideo {
  width: 100%; height: 100%; min-height: 0; max-height: 360px; object-fit: contain;
}
body.vobixConversation .mediaMessage .chatVideoExpand { gap: 0; }
body.vobixConversation .mediaMessage .chatVideoDuration {
  position: absolute; bottom: 9px; left: 10px; pointer-events: none;
  border-radius: 7px; padding: 3px 7px;
  background: #12344ce6; color: #fff; font: 600 12px/1.3 system-ui,sans-serif;
  font-variant-numeric: tabular-nums;
}
body.vobixConversation .mediaMessage .chatMediaQuality {
  margin: 0; padding: 3px 5px; font-size: 10px; line-height: 1;
}
body.vobixConversation .mediaMessage .chatDocumentLink {
  width: 100%; min-height: 86px; padding: 12px;
  gap: 10px; border-radius: 13px;
}
body.vobixConversation .mediaMessage .chatDocumentName { font-size: 14px; line-height: 1.35; }
body.vobixConversation .mediaMessage .chatDocumentDetails { gap: 6px; }
body.vobixConversation .mediaMessage .chatDocumentTypeBadge { font-size: 10px; }
body.vobixConversation .mediaMessage :is(button,a,[role=slider]):focus-visible {
  outline: 3px solid #0095ff; outline-offset: 2px;
}
body.vobixSeniorMode .messageRow:is(.mine,.theirs) .messageBubble.mediaMessage { width: min(420px,96%); max-width: min(420px,96%); }
body.vobixSeniorMode .voiceMessage .voiceTime { font-size: 13px; }
body.vobixSeniorMode .mediaMessage .chatDocumentName { font-size: 18px; }
@layer vobixLight {
  :where(body.vobixConversation:not(.seniorHighContrast):not(.contrast)) .mediaMessage :is(.voiceTime,.messageTime,.chatAttachmentMeta) { color: #365c73 !important; }
  :where(body.vobixConversation:not(.seniorHighContrast):not(.contrast)) .mediaMessage .voiceSpeedButton { background: #e8f6ff !important; color: #075c96 !important; border-color: #add7f0 !important; }
  :where(body.vobixConversation:not(.seniorHighContrast):not(.contrast)) .mediaMessage .chatAttachmentDownload { background: #e8f6ff !important; color: #075c96 !important; }
  :where(body.vobixConversation:not(.seniorHighContrast):not(.contrast)) .mediaMessage .chatVideoDuration { background: #12344ce6 !important; color: #fff !important; }
}

/* Narrow voice player; keep options in the separate footer. */
body.vobixConversation .messageRow:is(.mine,.theirs) .messageBubble.mediaMessage.voiceMessage{
 width:min(258px,86%);max-width:min(258px,86%);min-width:0;box-sizing:border-box;
 grid-template-columns:44px minmax(0,1fr) 44px;grid-template-rows:28px 18px auto;
 gap:4px 8px;padding:10px 10px 4px;border-radius:20px;
}
body.vobixConversation .voiceMessage .voiceSpeedButton{width:44px;min-width:44px;border-radius:13px;font-size:12px;}
body.vobixConversation .voiceMessage .voiceTime{font-weight:600;padding-bottom:0;}
body.vobixConversation .voiceMessage .mediaMessageFooter{min-height:36px;padding-top:0;}
html:is([data-vobix-font=large],[data-vobix-font=xlarge]) body.vobixConversation .messageRow:is(.mine,.theirs) .voiceMessage{width:min(280px,90%);max-width:min(280px,90%);}
body.vobixSeniorMode .messageRow:is(.mine,.theirs) .messageBubble.mediaMessage.voiceMessage{width:min(320px,96%);max-width:min(320px,96%);}

/* System emoji fonts preserve joined families, flags and skin tones. */
body.vobixConversation :is(.messageText,.messageInput,.chatDocumentName){
 font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI","Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif;
 overflow-wrap:anywhere;min-width:0;
}
body.vobixConversation .mediaMessage .chatDocumentName{white-space:normal;overflow-wrap:anywhere;}

/* Preserve the original media proportions instead of fitting tall media into
   a short, light preview box. The conversation scrolls around the full frame. */
body.vobixConversation .mediaMessage .chatMediaButton{
 display:block;width:100%;padding:0;overflow:hidden;background:transparent;
}
body.vobixConversation .mediaMessage .chatMediaImage{
 display:block;width:100%;height:auto;max-height:none;min-height:0;
 aspect-ratio:auto;object-fit:contain;transform:none;background:transparent;
}
body.vobixConversation .mediaMessage .chatVideoThumbnail{
 width:100%;max-height:none;aspect-ratio:var(--media-ratio,4 / 3);
}
body.vobixConversation .mediaMessage .chatVideoThumbnail .chatMediaVideo{
 display:block;width:100%;height:100%;max-height:none;object-fit:contain;
}
@layer vobixLight{
 :where(body.vobixConversation:not(.seniorHighContrast):not(.contrast)) .mediaMessage :is(.chatMediaButton,.chatMediaImage){background:transparent!important}
}

/* Expand opened photos to the viewport; retain original proportions and zoom. */
#photoViewer.photoViewer,html.vobixInstalled #photoViewer.photoViewer{padding:0;background:#000;}
#photoViewer .photoViewerStage{position:absolute;inset:0;width:100%;height:100%;}
#photoViewer .photoViewerImage{width:100%;height:100%;max-width:100%;max-height:100%;object-fit:contain;}
#photoViewer .photoViewerToolbar{position:absolute;top:0;left:0;right:0;z-index:2;background:linear-gradient(#0009,transparent);}
@layer vobixLight{
 body #photoViewer,body #photoViewer .photoViewerStage,body #photoViewer .photoViewerImage{background:#000!important;}
}

/* Compact photo messages; the separate tap-to-open viewer stays full screen. */
body.vobixConversation .messageRow:is(.mine,.theirs) .messageBubble.mediaMessage:has(.chatMediaImage){
 width:fit-content;max-width:min(280px,80%);min-width:0;
}
body.vobixConversation .mediaMessage .chatMediaButton:has(.chatMediaImage){
 display:flex;justify-content:center;align-items:center;width:auto;max-width:100%;margin-inline:auto;
}
body.vobixConversation .mediaMessage .chatMediaImage{
 width:auto;height:auto;max-width:min(260px,68vw);max-height:min(380px,48dvh);
 min-height:0;object-fit:contain;aspect-ratio:auto;margin-inline:auto;background:transparent;
}

/* Sent videos are compact cards; recording and the full-screen player are separate. */
body.vobixConversation .messageRow:is(.mine,.theirs) .messageBubble.mediaMessage:has(.chatVideoThumbnail){
 width:fit-content;max-width:min(280px,80%);min-width:0;
}
body.vobixConversation .mediaMessage .chatVideoThumbnail{
 width:min(260px,68vw,calc(380px * var(--media-ratio,1.333333)),calc(48dvh * var(--media-ratio,1.333333)));
 max-width:100%;height:auto;max-height:min(380px,48dvh);
 aspect-ratio:var(--media-ratio,4 / 3);margin-inline:auto;
}
body.vobixConversation .mediaMessage .chatVideoThumbnail .chatMediaVideo{
 width:100%;height:100%;max-height:100%;min-height:0;object-fit:contain;
}

/* Photos and videos share a compact message frame. Opening keeps the full file. */
body.vobixConversation .messageRow:is(.mine,.theirs) .messageBubble.mediaMessage.visualMediaMessage{
 position:relative;width:min(280px,82%);max-width:min(280px,82%);min-width:0;box-sizing:border-box;
 padding:3px;border-radius:14px;overflow:visible;
}
body.vobixConversation:not(.contrast):not(.seniorHighContrast) .messageRow.mine .messageBubble.visualMediaMessage{background:#d9efff!important;color:#18374b!important;border:0!important;box-shadow:0 1px 2px #0002!important}
body.vobixConversation:not(.contrast):not(.seniorHighContrast) .messageRow.theirs .messageBubble.visualMediaMessage{background:#fff!important;color:#18374b!important;border:0!important;box-shadow:0 1px 2px #0002!important}
body.vobixConversation .mediaMessage.visualMediaMessage :is(.chatMediaButton,.chatVideoThumbnail){
 display:block;width:100%;max-width:none;height:auto;max-height:none;min-height:0;
 aspect-ratio:var(--media-preview-ratio,4 / 3);margin:0;padding:0;border:0;border-radius:11px;overflow:hidden;
}
body.vobixConversation .visualMediaMessage :is(.chatMediaImage,.chatVideoThumbnail .chatMediaVideo){
 display:block;width:100%;height:100%;max-width:none;max-height:none;min-height:0;
 margin:0;border-radius:0;object-fit:cover;aspect-ratio:auto;
}
body.vobixConversation .messageRow .visualMediaMessage .mediaMessageFooter{min-height:24px;padding:3px 5px 1px;gap:5px}
body.vobixConversation .visualMediaMessage .mediaMessageInfo{flex:0 1 auto;gap:4px}
body.vobixConversation .visualMediaMessage .chatAttachmentMeta{display:none}
body.vobixConversation .visualMediaMessage .messageMeta{justify-content:flex-end;flex:1;margin:0;padding:0;min-height:18px}
body.vobixConversation .visualMediaMessage .messageTime{font-size:10px}
body.vobixConversation .messageRow .visualMediaMessage .mediaMessageFooter>.messageMenuButton{
 position:absolute;top:50%;inset-inline-end:auto;left:auto;right:-46px;transform:translateY(-50%);
 width:44px;height:44px;min-width:44px;border-radius:50%;background:#e7eff5;color:#4b6474;font-size:21px;
}
body.vobixConversation .messageRow.mine .visualMediaMessage .mediaMessageFooter>.messageMenuButton{right:auto;left:-46px}
body.vobixConversation .visualMediaMessage .messageActions>.chatAttachmentDownload{
 display:flex;align-items:center;gap:10px;position:static;width:100%;height:auto;min-height:44px;
 box-sizing:border-box;padding:10px 12px;margin:0;border:0;border-radius:9px;color:inherit;background:transparent;
 text-decoration:none;font:500 14px/1.4 system-ui;
}
body.vobixConversation .visualMediaMessage .messageActions>.chatAttachmentDownload svg{flex:0 0 22px;width:22px;height:22px}
body.vobixConversation .visualMediaMessage .chatVideoExpand svg{width:54px;height:54px;filter:drop-shadow(0 2px 6px #0004)}
body.vobixConversation .visualMediaMessage .chatVideoExpand svg circle{fill:#111b21a8;stroke:#ffffffb3;stroke-width:1}
body.vobixConversation .visualMediaMessage .chatVideoDuration{left:9px;bottom:8px;padding:2px 6px;border-radius:6px;background:#0008;font-weight:500}
@layer vobixLight{
 body.vobixConversation:not(.contrast):not(.seniorHighContrast) .messageRow.mine .messageBubble.visualMediaMessage{background:#d9efff!important;color:#18374b!important;border:0!important;box-shadow:0 1px 2px #0002!important}
 body.vobixConversation:not(.contrast):not(.seniorHighContrast) .messageRow.theirs .messageBubble.visualMediaMessage{background:#fff!important;color:#18374b!important;border:0!important;box-shadow:0 1px 2px #0002!important}
 body.vobixConversation .visualMediaMessage :is(.messageMeta,.messageTime,.messageStatus){color:#4b6474!important}
 body.vobixConversation .visualMediaMessage .messageStatus.read{color:#087ae0!important}
 body.vobixConversation:not(.contrast):not(.seniorHighContrast) .visualMediaMessage .mediaMessageFooter>.messageMenuButton{background:#e7eff5!important;color:#4b6474!important;box-shadow:none!important;border:0!important}
 body.vobixConversation .visualMediaMessage .messageActions>.chatAttachmentDownload{background:transparent!important;color:inherit!important}
}
