.bubble audio, .gmsg audio { display: block; width: min(100%, 320px); margin-block: 8px; }
.message-transcription { white-space: pre-wrap; border-left: 2px solid var(--teal); padding-left: 10px; }
.message-toolbar { display: flex; flex-wrap: wrap; gap: .4rem; padding: .5rem; align-items: center; }
.message-toolbar[hidden] { display: none; }
.message-search-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin: .65rem 0 .25rem; padding: .65rem; border: 1px solid color-mix(in srgb, var(--teal) 28%, var(--line)); border-radius: 14px; background: color-mix(in srgb, var(--panel-raised) 84%, var(--teal) 16%); }
.message-search-controls[hidden] { display: none; }
.message-search-controls input[type="search"] { min-width: min(220px, 100%); flex: 1 1 220px; min-height: 42px; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--ink); }
.message-search-controls button { min-height: 40px; padding: .55rem .8rem; border: 1px solid color-mix(in srgb, var(--teal) 35%, var(--line)); border-radius: 11px; background: var(--panel); color: var(--teal); }
.message-search-toggle { display: grid; flex: 0 0 auto; place-items: center; }
.message-search-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.chat-tools, .group-tools { display: flex; align-items: center; gap: 8px; }
.group-tools { margin-left: auto; }
.message-toolbar input[type="search"] { min-width: 0; flex: 1 1 160px; max-width: 100%; }
.message-search-results { max-height: 35vh; overflow: auto; display: grid; gap: .4rem; }
.message-search-results:empty, .message-draft:empty { display: none; }
.message-draft { padding: .5rem; border-top: 1px solid var(--border, #34495a); overflow-wrap: anywhere; }
.message-draft p { margin: .2rem 0; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.message-quote { border-left: 3px solid var(--accent, #2fd4d0); margin: .2rem 0; padding-left: .5rem; opacity: .8; overflow-wrap: anywhere; }
.message-reactions { display: flex; gap: .3rem; flex-wrap: wrap; }
.message-reactions button[aria-pressed="true"] { outline: 1px solid var(--accent, #2fd4d0); border-radius: .4rem; }
.message-reactions .reaction-animation-pop { animation: reactionSpring .46s cubic-bezier(.2, .85, .35, 1.35); }
.message-reactions .reaction-animation-glow { animation: reactionGlow .7s ease-out; }
@keyframes reactionSpring { 0% { transform: scale(.72); } 58% { transform: scale(1.28); } 82% { transform: scale(.94); } 100% { transform: scale(1); } }
@keyframes reactionGlow { 0% { box-shadow: 0 0 0 0 rgba(47, 212, 208, .55); } 65% { box-shadow: 0 0 0 7px rgba(47, 212, 208, .16); } 100% { box-shadow: 0 0 0 10px rgba(47, 212, 208, 0); } }
@media (prefers-reduced-motion: reduce) {
  .message-reactions .reaction-animation-pop,
  .message-reactions .reaction-animation-glow { animation-duration: .01ms; }
}
.message-image { display: block; max-width: min(100%, 320px); max-height: 300px; object-fit: contain; margin-top: .4rem; }
.bubble, .gmsg { overflow-wrap: anywhere; }
.bubble > button, .gmsg > button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; display: block; }
.message-media { min-width: 0; max-width: 100%; }
.message-media > button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; display: block; }
.message-media > button[hidden] { display: none; }
.message-editor { width: min(90vw, 480px); border-radius: 1rem; padding: 1rem; background: var(--panel, #102234); color: inherit; }
.message-editor textarea { width: 100%; min-height: 120px; box-sizing: border-box; resize: vertical; }
.message-edited { opacity: .7; margin-right: .4rem; }
.chat-emoji-picker { min-width: 0; max-width: 100%; }
.chat-emoji-picker > summary { cursor: pointer; list-style: none; padding: 8px; color: var(--teal); }
.chat-emoji-picker > summary::-webkit-details-marker { display: none; }
.message-toolbar .chat-emoji-picker > summary { font-size: 24px; line-height: 1; width: 40px; height: 40px; text-align: center; }
.chat-emoji-panel { width: min(320px, 100%); max-height: 260px; overflow-y: auto; padding: 10px; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 8px; }
.message-toolbar .chat-emoji-picker[open] { flex: 1 1 100%; }
.chat-emoji-panel > strong { display: block; font-size: 12px; color: var(--muted); margin-block: 4px; }
.chat-emoji-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(32px, 1fr)); gap: 3px; }
.bubble > button[hidden], .gmsg > button[hidden] { display: none; }
.chat-emoji-grid button { display: grid; place-items: center; min-width: 0; width: 100%; height: 38px; padding: 2px; font-size: 23px; line-height: 1; border-radius: 4px; }
.message-toolbar .chat-emoji-grid button { font-size: 23px; }
.bubble .message-photo-open, .gmsg .message-photo-open { display: block; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.message-photo-open .message-image { margin: 0; border-radius: 6px; }
.message-photo-viewer { width: min(95vw, 1000px); max-height: 95vh; padding: 12px; }
.message-photo-viewer img { display: block; max-width: 100%; max-height: 80vh; object-fit: contain; margin: auto; }
.message-photo-viewer > button { display: block; margin-inline-start: auto; font-size: 24px; width: 40px; height: 40px; }
@media (max-width: 480px) {
  .message-toolbar { gap: .25rem; }
  .message-toolbar button, .message-search-controls button { font-size: .75rem; }
  .message-search-controls { gap: .35rem; padding: .5rem; }
}
.message-composer { position: relative; display: flex; align-items: center; gap: 6px; padding: 8px; border-top: 1px solid var(--line); background: var(--panel); min-height: 60px; }
.message-composer .message-toolbar { display: contents; }
.message-composer .message-toolbar[hidden] { display: none; }
.message-composer > input { order: 1; flex: 1 1 0; min-width: 0; width: auto; border: 0; background: transparent; padding: 10px 4px; }
.composer-attachments { order: 0; }
.message-composer .composer-emoji { order: 2; }
.message-composer .composer-record { order: 3; }
.message-composer > button[type=submit] { order: 4; flex: 0 0 40px; width: 40px; height: 40px; min-height: 40px; padding: 0; font-size: 0; background: var(--panel-raised) url('/assets/ui-icons/send.svg') center / 26px no-repeat; }
.composer-attachments > summary, .message-composer .composer-emoji > summary, .message-composer .composer-record { display: grid; place-items: center; width: 40px; height: 40px; padding: 8px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; list-style: none; flex: 0 0 40px; }
.composer-attachments summary::-webkit-details-marker { display: none; }
.message-composer img { width: 24px; height: 24px; object-fit: contain; }
.composer-smile { font-size: 30px; line-height: 24px; color: var(--muted); }
.message-composer .composer-emoji[open] { flex: 0 0 auto; }
.message-composer .chat-emoji-panel, .composer-attachment-menu { position: absolute; bottom: calc(100% + 6px); z-index: 20; max-height: min(320px, 45vh); overflow-y: auto; width: min(320px, calc(100% - 16px)); box-shadow: 0 8px 30px #0005; }
.message-composer .chat-emoji-panel { inset-inline-end: 8px; }
.composer-attachment-menu { inset-inline-start: 8px; display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--panel-raised); }
.composer-attachment-menu button { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 10px; text-align: start; }
.message-composer .composer-record[aria-label="Остановить запись"] { color: #ff7777; background: #ff77771a; font-size: 24px; }
.message-text:empty { display: none; }
.message-photo-placeholder, .message-media .message-photo-open { width: min(320px, 100%); aspect-ratio: 4 / 3; min-width: 0; background: var(--panel-raised); border-radius: 6px; }
.message-media-photo { width: 320px; max-width: 100%; }
.message-photo-placeholder { display: grid; place-items: center; padding: 12px; color: var(--muted); font-size: 12px; text-align: center; }
.message-photo-placeholder[hidden] { display: none; }
.message-media .message-photo-open { display: block; padding: 0; border: 0; cursor: zoom-in; }
.message-photo-open .message-image { width: 100%; height: 100%; max-height: none; max-width: 100%; object-fit: contain; }
.message-photo-viewer { position: fixed; inset: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; background: #080d13f5; padding: 12px; }
.message-photo-viewer::backdrop { background: #000c; }
.message-photo-viewer img { width: 100%; height: calc(100dvh - 80px); max-height: none; object-fit: contain; }
.message-photo-header { display: flex; align-items: center; gap: 8px; height: 48px; color: #fff; }
.message-photo-header > span { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.message-photo-header button { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; border: 0; background: #ffffff12; color: #fff; border-radius: 6px; font-size: 26px; }
.voice-message { --voice-played: var(--teal); --voice-idle: #ffffff4d; display: flex; align-items: center; gap: 12px; width: 300px; max-width: 100%; min-height: 56px; }
.bubble.mine .voice-message, .gmsg.mine .voice-message { --voice-played: #fff; --voice-idle: #ffffff6b; }
.voice-play { display: grid; place-items: center; flex: 0 0 46px; width: 46px; height: 46px; padding: 0; background: var(--teal); color: #071a23; border: 0; border-radius: 50%; box-shadow: 0 2px 8px #0003; transition: transform .12s; }
.voice-play:hover:not(:disabled) { transform: scale(1.06); }
.voice-play:disabled { opacity: .7; }
.voice-play svg { width: 22px; height: 22px; }
.voice-message:not(.playing) .voice-play svg { margin-inline-start: 2px; }
.bubble.mine .voice-play { background: #fff; color: var(--blue, #1f6fd0); }
.voice-middle { flex: 1; min-width: 0; display: grid; gap: 4px; }
.voice-waveform { display: block; width: 100%; height: 32px; cursor: pointer; touch-action: none; border-radius: 6px; }
.voice-waveform:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.voice-clock { color: inherit; opacity: .7; font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.voice-speed { align-self: flex-start; min-width: 34px; padding: 2px 8px; border: 0; border-radius: 999px; background: #ffffff1f; color: inherit; font-size: 12px; font-weight: 600; }
.voice-message:not(.playing) .voice-speed { opacity: .7; }
.voice-message audio[hidden] { display: none; }
.composer-reply { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-inline-start: 3px solid var(--teal); background: var(--panel-raised); }
.composer-reply-copy { flex: 1; min-width: 0; }
.composer-reply strong { color: var(--teal); font-size: 12px; }
.composer-reply p { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.composer-reply > button { flex: 0 0 32px; width: 32px; height: 32px; font-size: 24px; }
.message-quote { border-inline-start: 3px solid var(--teal); border-left: 0; border-radius: 4px; background: #ffffff0a; padding: 6px 8px; }
.message-quote button { display: grid; gap: 4px; text-align: start; max-width: 100%; }
.message-quote strong { color: var(--teal); font-size: 12px; }
.message-quote span { font-size: 13px; }
.message-location { display: block; padding: 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--teal); font-size: 13px; overflow-wrap: anywhere; }
.message-map-card { display: grid; gap: 2px; width: 320px; max-width: 100%; overflow: hidden; background: transparent; border-radius: 14px; }
.message-map-view { position: relative; width: 100%; height: 210px; border-radius: 12px; background: #e8e4d8; overflow: hidden; z-index: 0; isolation: isolate; }
.message-map-view.message-map-unavailable { background: var(--panel); }
.message-map-view .leaflet-control-attribution { font-size: 9px; background: #fffc; }
.bubble.has-map, .gmsg.has-map { width: min(340px, 96%); max-width: 96%; padding: 4px; }
.message-map-card strong, .message-map-card small { padding-inline: 8px; overflow-wrap: anywhere; }
.message-map-card strong { margin-top: 6px; }
.message-map-card small { color: var(--muted); font-size: 11px; }
.message-map-card .message-location { padding: 4px 8px 8px; border: 0; }
.message-map-pin { background: transparent; border: 0; }
.map-pin { position: relative; width: 60px; height: 76px; filter: drop-shadow(0 2px 4px #0006); }
.map-pin-avatar { position: absolute; top: 0; left: 4px; display: grid; place-items: center; width: 52px; height: 52px; overflow: hidden; border: 3px solid #fff; border-radius: 50%; background: var(--teal); color: #062029; font: 700 22px/1 system-ui, sans-serif; }
.map-pin-avatar img { width: 100%; height: 100%; object-fit: cover; }
.map-pin::before { content: ""; position: absolute; top: 49px; left: 24px; width: 12px; height: 12px; background: #fff; transform: rotate(45deg); border-radius: 2px; }
.map-pin-dot { position: absolute; left: 24px; top: 64px; width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; background: #ff4b4b; }
.composer-live-stop { flex: 0 0 auto; padding: 10px; min-height: 40px; background: #e85a5a22; color: #ff9a9a; border: 1px solid #e85a5a55; border-radius: 6px; }
.composer-live-stop[hidden] { display: none; }
.composer-photo-menu > summary { display: flex; align-items: center; gap: 14px; padding: 10px; min-height: 44px; cursor: pointer; list-style: none; }
.composer-photo-menu > summary::-webkit-details-marker { display: none; }
.composer-photo-menu > button { width: 100%; padding-inline-start: 48px; }
.location-sheet { width: min(520px, calc(100vw - 24px)); max-width: 100vw; max-height: min(92dvh, var(--app-viewport-height, 92dvh)); padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); overflow-y: auto; }
.location-sheet::backdrop { background: #000a; }
.location-sheet > header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.location-sheet h2 { flex: 1; margin: 0; font-size: 19px; }
.location-sheet header button { width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 28px; }
.location-picker-map { width: 100%; height: 270px; min-height: 160px; background: var(--panel-raised); color: #172029; }
.location-sheet-controls { display: grid; gap: 8px; padding: 12px 16px max(16px, env(safe-area-inset-bottom)); }
.location-sheet-controls > button { min-height: 46px; text-align: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-raised); color: var(--ink); }
.location-sheet-controls .location-live-start { color: #74df9b; }
.location-sheet-controls .location-point-send { color: var(--teal); }
.location-privacy, .location-feedback { margin: 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.location-duration { display: grid; gap: 12px; }
.location-duration[hidden], .location-sheet button[hidden] { display: none; }
.location-duration h3 { font-size: 16px; margin: 4px 0; }
.location-duration label { display: flex; align-items: center; gap: 12px; min-height: 42px; }
.location-duration input[type=radio] { width: 22px; height: 22px; accent-color: var(--teal); }
.location-duration p { font-size: 12px; color: var(--muted); margin: 0; }
.location-duration-actions { display: flex; justify-content: flex-end; gap: 12px; }
.location-duration-actions button { min-height: 42px; padding: 8px 14px; color: var(--teal); }
@media (max-width: 760px), (pointer: coarse) and (max-width: 1023px) {
  .location-sheet { position: fixed; inset: auto 0 0; width: 100%; margin: 0; border-radius: 8px 8px 0 0; }
  .location-picker-map { height: min(35dvh, 270px); }
}
@media (max-width: 760px), (pointer: coarse) and (max-width: 1023px) {
  body.app-active { position: fixed; inset-inline: 0; top: var(--app-viewport-top, 0px); bottom: auto; height: var(--app-viewport-height, 100dvh); min-height: 0; overflow: hidden; overscroll-behavior: none; }
  body.app-active .app-shell { height: 100%; min-height: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); gap: 0; }
  body.app-active .workspace { min-height: 0; border-radius: 0; }
  body.app-active .chat-pane { min-height: 0; padding: 8px; overflow: hidden; }
  body.app-active .chat-body { min-height: 0; overscroll-behavior: contain; }
  body.app-active .chats-page.chat-open .chat-list-pane { display: none; }
  body.app-active .chats-page.chat-open .chat-pane { display: flex; width: 100%; }
  body.app-active .chat-back:not(.hidden) { display: grid; }
  body.app-active .message-composer { flex: 0 0 auto; padding: 6px 2px; gap: 2px; }
  body.app-active .message-composer > input { font-size: 16px; }
  body.app-active .composer-attachments > summary, body.app-active .composer-emoji > summary,
  body.app-active .composer-record { width: 36px; height: 40px; flex-basis: 36px; padding: 6px; }
  body.app-active .message-composer > button[type=submit] { width: 36px; flex-basis: 36px; }
  body.app-active.keyboard-open .tabbar { display: none; }
  .message-composer .chat-emoji-panel, .composer-attachment-menu { max-height: min(300px, calc(var(--app-viewport-height, 100dvh) * .5)); }
}
