/* Local messenger presentation. Keep the viewport/flex chain intact. */
@media(max-width:767px){
body[data-chat-open="true"]{overflow:hidden}

body[data-chat-open="true"] .phone{position:fixed;inset-inline:0;top:var(--tg-top,0);width:100%;height:var(--tg-height,100vh);min-height:0;margin:0;border:0;border-radius:0;overflow:hidden;box-shadow:none;transform:none}

body[data-chat-open="true"] #app{height:100%;min-height:0}

}

.tg-root.app-root{height:100%;min-height:0;padding:0}

.tg-conversation{display:flex;flex-direction:column;height:100%;min-height:0;background:var(--bg);color:var(--fg)}

.tg-header{display:flex;gap:10px;align-items:center;flex-shrink:0;padding:calc(8px + env(safe-area-inset-top,0px)) 8px 8px;background:var(--surface);border-bottom:1px solid var(--border-subtle)}

.tg-icon,.tg-send{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;min-width:44px;border:0;border-radius:12px;color:var(--secondary);background:transparent;cursor:pointer;transition:background var(--duration-control)}

.tg-icon svg,.tg-send svg{width:20px;height:20px}
.tg-icon:hover{background:var(--hover);color:var(--fg)}
.tg-icon:active{background:var(--elevated)}

.tg-peer{display:flex;flex:1;min-width:0;flex-direction:column;gap:3px}
.tg-peer strong{font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tg-peer span{font-size:12px;color:var(--secondary)}

.tg-product{display:flex;align-items:center;gap:10px;flex-shrink:0;padding:8px 16px;background:var(--surface);border:0;border-bottom:1px solid var(--border);text-align:start;color:var(--fg)}

.tg-product img{width:40px;height:40px;object-fit:contain;border-radius:8px;background:var(--image-surface)}
.tg-product span{flex:1;min-width:0}
.tg-product strong{display:block;font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tg-product small{font-size:12px;color:var(--secondary)}
.tg-product>svg{width:20px;height:20px}
.tg-product:hover{background:var(--hover)}

.tg-message-wrap{flex:1;min-height:0;position:relative}
.tg-messages{height:100%;overflow:auto;overscroll-behavior:contain;padding:16px 12px;scrollbar-width:thin}

.tg-message{width:fit-content;max-width:85%;margin-block:4px;padding:10px 12px 2px;border-radius:14px;background:var(--message-other);border:1px solid var(--border-subtle);overflow-wrap:anywhere;outline-offset:3px}

.tg-message.mine{margin-inline-start:auto;background:var(--message-own);color:var(--message-own-fg);border-color:var(--border-subtle);border-end-end-radius:5px}
.tg-message.other{margin-inline-end:auto;border-end-start-radius:5px}

.tg-text{white-space:pre-wrap;font-size:16px;line-height:1.65}
.tg-message-meta{display:flex;align-items:center;justify-content:flex-end;gap:5px;font-size:11px;color:var(--secondary);min-height:32px}
.tg-message-meta .tg-icon{width:44px;height:44px;min-width:44px;border-radius:8px;color:inherit}
.tg-message-meta .tg-icon svg{width:16px;height:16px}

.tg-local-status{display:inline-flex;align-items:center;justify-content:center}
.tg-local-status svg{width:13px;height:13px}

.tg-message .tg-quote{display:block;border:0;border-inline-start:3px solid currentColor;border-radius:5px;background:color-mix(in srgb,currentColor 10%,transparent);color:inherit;text-align:start;padding:8px;min-height:44px;width:100%;margin-bottom:6px;font-size:13px;max-height:90px;overflow:hidden}

.tg-photos{display:grid;gap:3px;min-width:160px;max-width:320px;margin:0 -4px}
.tg-photos.album{grid-template-columns:repeat(2,minmax(0,1fr))}
.tg-photos button{border:0;padding:0;background:transparent;overflow:hidden;border-radius:8px;min-height:44px}
.tg-photos img{display:block;width:100%;height:auto;max-height:320px;object-fit:contain}
.tg-photos.album img{height:140px;object-fit:cover}

.tg-day{width:fit-content;margin:16px auto 10px;background:var(--surface);color:var(--secondary);padding:5px 10px;border:1px solid var(--border-subtle);border-radius:8px;font-size:12px}
.tg-load{display:block;min-height:44px;margin:0 auto;border:0;background:var(--surface);color:var(--fg);border-radius:12px;padding:8px 16px}
.tg-empty{text-align:center;padding:32px 16px;color:var(--secondary)}
.tg-empty svg{width:40px;height:40px}
.tg-deleted{font-style:italic;font-size:14px}
.tg-offer{display:flex;flex-direction:column;gap:4px;font-size:14px}
.tg-offer strong{font-size:22px}

#tg-scroll-bottom{position:absolute;inset-inline-end:16px;bottom:12px;background:var(--surface);box-shadow:var(--nav-shadow)}
#tg-scroll-bottom svg{transform:rotate(90deg)}
[data-chat-action][hidden]{display:none!important}

.tg-composer{flex-shrink:0;background:var(--surface);border-top:1px solid var(--border);padding:6px 8px calc(6px + env(safe-area-inset-bottom,0px))}
.tg-composer form{display:flex;gap:6px;align-items:flex-end}
.tg-composer textarea{resize:none;flex:1;min-width:0;min-height:44px;max-height:128px;border:1px solid var(--border-control);border-radius:12px;background:var(--bg);color:var(--fg);padding:10px 14px;font:16px/22px var(--font);overflow:auto}
.tg-composer textarea::placeholder{color:var(--secondary);opacity:1}
.tg-send{background:var(--primary);color:var(--primary-fg)}
.tg-send:hover{background:var(--primary-hover)}
.tg-send:active{background:var(--primary-active)}
.tg-compose-quote{display:flex;align-items:center;gap:8px;border-inline-start:3px solid var(--primary);padding-inline-start:10px;margin:4px 8px 8px}
.tg-compose-quote span{flex:1;min-width:0}
.tg-compose-quote strong,.tg-compose-quote small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tg-compose-quote strong{font-size:13px;color:var(--primary)}
.tg-compose-quote small{font-size:13px;color:var(--secondary)}

#tg-attachments{display:flex;gap:8px;overflow:auto}
.tg-attachment{position:relative;flex-shrink:0;margin-bottom:8px}
.tg-attachment img{width:76px;height:76px;object-fit:cover;border-radius:10px}
.tg-attachment .tg-icon{position:absolute;top:0;inset-inline-end:0;background:var(--toast-bg);color:var(--toast-fg)}
.tg-warning{font-size:13px;line-height:1.7;padding:10px 12px;margin-bottom:8px;border-radius:10px;background:var(--warning-surface);color:var(--warning)}
.tg-warning button{min-height:44px;color:var(--fg);text-decoration:underline;background:transparent;border:0}

.tg-chat-row{display:flex;align-items:center;gap:12px;width:100%;padding:14px 4px;background:transparent;color:var(--fg);border:0;border-bottom:1px solid var(--border-subtle);border-radius:12px;text-align:start;cursor:pointer;transition:background var(--duration-control)}
.tg-chat-main{display:flex;flex-direction:column;gap:3px;flex:1;min-width:0}
.tg-chat-main strong{font-size:16px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.tg-chat-product,.tg-chat-preview{font-size:13px;color:var(--secondary);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.tg-chat-preview{font-size:14px}
.tg-chat-preview.draft{color:var(--warning)}
.tg-chat-row:hover{background:var(--hover)}
.tg-chat-row:active{background:var(--elevated)}
.tg-chat-row[aria-current="page"],.tg-chat-row.selected{background:var(--accent)}
.tg-chat-end{display:flex;flex-direction:column;align-items:center;gap:8px;font-size:12px;color:var(--secondary);flex-shrink:0}

.tg-dialog{position:fixed;inset:0;margin:auto;width:calc(100% - 32px);max-width:440px;max-height:85vh;max-height:85dvh;overflow:auto;padding:20px;border:1px solid var(--border);border-radius:16px;background:var(--surface);color:var(--fg);box-shadow:var(--shadow-dialog)}
.tg-dialog::backdrop{background:var(--scrim)}
.tg-dialog-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
.tg-dialog h2{font-size:22px;line-height:1.5;margin:0}
.tg-dialog p{font-size:15px;line-height:1.8;color:var(--secondary)}
.tg-menu-row{display:block;width:100%;min-height:48px;padding:12px;border:0;border-bottom:1px solid var(--border-subtle);border-radius:10px;background:transparent;color:var(--fg);text-align:start;font-size:15px;cursor:pointer}
.tg-menu-row:hover{background:var(--hover)}
.tg-menu-row[data-chat-action="ask-delete"],.tg-menu-row[data-chat-action="delete"]{color:var(--danger)}
.tg-menu-row[data-chat-action="ask-delete"]:hover,.tg-menu-row[data-chat-action="delete"]:hover{background:var(--danger-surface)}
.tg-full-image{display:block;width:100%;max-height:65vh;object-fit:contain}
.tg-copy{width:100%;min-height:120px;border:1px solid var(--border-control);border-radius:12px;background:var(--bg);color:var(--fg);font-size:16px;padding:12px}
.tg-sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}

.tg-composer textarea:focus{border-color:var(--focus);outline:2px solid var(--focus);outline-offset:2px}

.tg-conversation button:focus-visible,.tg-chat-row:focus-visible,.tg-dialog button:focus-visible,.tg-conversation textarea:focus-visible{outline:2px solid var(--focus-ring);outline-offset:2px}

@media(prefers-reduced-motion:reduce){.tg-conversation *,.tg-dialog *{scroll-behavior:auto!important;animation:none!important;transition:none!important}
}

