/* MEDIAVIEWER 22.11.2026: просмотр фото/видео в стиле Telegram */
#lightbox.lb-ready {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: rgba(0,0,0,.94);
  z-index: 40;
  overflow: hidden;
  color: #fff;
  font-family: inherit;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#lightbox.lb-ready[hidden] { display: none !important; }
#lightbox.lb-ready .lightbox-dl { display: none; }

.lb-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 4;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 18px 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,.72), rgba(0,0,0,.28) 70%, transparent);
  pointer-events: none;
}
.lb-top > * { pointer-events: auto; }
.lb-meta { min-width: 0; flex: 1; line-height: 1.2; }
.lb-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-date { font-size: 12.5px; opacity: .72; margin-top: 2px; }
.lb-counter {
  flex: none; font-size: 13.5px; font-weight: 600; letter-spacing: .02em;
  padding: 4px 8px; opacity: .92;
}
.lb-tools { display: flex; align-items: center; gap: 2px; }

.lb-icon, #lightbox.lb-ready #lightbox-close {
  position: static; display: grid; place-items: center;
  width: 40px; height: 40px; margin: 0; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: #fff;
  cursor: pointer; flex: none;
  text-decoration: none;
}
.lb-icon:hover, #lightbox.lb-ready #lightbox-close:hover { background: rgba(255,255,255,.12); }
.lb-icon:active, #lightbox.lb-ready #lightbox-close:active { background: rgba(255,255,255,.2); transform: scale(.96); }
.lb-icon svg, #lightbox.lb-ready #lightbox-close svg { display: block; width: 22px; height: 22px; }
#lightbox.lb-ready #lightbox-close { font-size: 0; }

.lb-stage {
  flex: 1; min-height: 0; width: 100%;
  display: grid; place-items: center;
  position: relative;
  z-index: 1;
}
#lightbox.lb-ready #lightbox-img,
#lightbox.lb-ready #lightbox-video {
  max-width: 100vw; max-height: 100vh;
  width: auto; height: auto;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
}
#lightbox.lb-ready #lightbox-video { width: 100%; height: 100%; background: #000; }
#lightbox.lb-ready.lb-video #lightbox-img { display: none !important; }
#lightbox.lb-ready.lb-photo #lightbox-video { display: none !important; }

.lb-nav {
  position: absolute; top: 50%; z-index: 3;
  width: 44px; height: 64px; margin-top: -32px;
  border: 0; border-radius: 14px;
  background: rgba(0,0,0,.35); color: #fff;
  cursor: pointer; display: grid; place-items: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background .15s, opacity .15s;
}
.lb-nav:hover { background: rgba(0,0,0,.55); }
.lb-nav[hidden], .lb-nav.lb-off { display: none; }
#lb-prev { left: 10px; }
#lb-next { right: 10px; }
.lb-nav svg { width: 26px; height: 26px; }

.lb-vidbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  padding: 18px 16px 14px;
  background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,.2) 80%, transparent);
  display: flex; align-items: center; gap: 10px;
}
.lb-vidbar[hidden] { display: none !important; }
.lb-vbtn {
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; color: #fff; cursor: pointer;
  display: grid; place-items: center; flex: none; padding: 0;
}
.lb-vbtn:hover { background: rgba(255,255,255,.12); }
.lb-vbtn svg { width: 22px; height: 22px; }
.lb-seek {
  flex: 1; height: 4px; border-radius: 99px;
  -webkit-appearance: none; appearance: none;
  background: rgba(255,255,255,.25); outline: none;
}
.lb-seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; cursor: pointer; border: 0;
}
.lb-time { font-size: 12.5px; font-variant-numeric: tabular-nums; opacity: .9; min-width: 78px; text-align: center; }
.lb-speed {
  border: 0; background: rgba(255,255,255,.12); color: #fff;
  border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 12.5px; font-weight: 700;
  cursor: pointer; min-width: 44px;
}
.lb-speed:hover { background: rgba(255,255,255,.2); }

.lb-ctx {
  position: fixed; z-index: 1100; min-width: 220px; padding: 6px;
  background: rgba(28, 28, 30, .92);
  color: #f2f2f7;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.55);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  animation: lb-ctx-in .14s cubic-bezier(.2,.8,.3,1);
}
@keyframes lb-ctx-in { from { opacity: 0; transform: scale(.94); } }
.lb-ctx.lb-ctx-out { animation: lb-ctx-out .12s ease forwards; pointer-events: none; }
@keyframes lb-ctx-out { to { opacity: 0; transform: scale(.96); } }
.lb-ctx button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 14px; border: 0; background: transparent; color: inherit;
  font: inherit; font-size: 15.5px; text-align: left; cursor: pointer;
  border-radius: 10px;
}
.lb-ctx button:hover { background: rgba(255,255,255,.1); }
.lb-ctx button:active { background: rgba(255,255,255,.16); }
.lb-ctx svg { flex: none; width: 20px; height: 20px; opacity: .92; }
.lb-ctx button.danger { color: #ff6b6b; }

#lb-editor {
  position: fixed; inset: 0; z-index: 1200;
  background: #0b0b0d; color: #fff;
  display: flex; flex-direction: column;
}
#lb-editor[hidden] { display: none !important; }
.lbe-top, .lbe-bot {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  background: #121215;
  flex: none;
}
.lbe-top { padding-top: 10px; }
.lbe-title { flex: 1; text-align: center; font-weight: 650; font-size: 16px; }
.lbe-stage {
  flex: 1; min-height: 0; display: grid; place-items: center;
  overflow: hidden; background: #000; position: relative;
  touch-action: none;
}
.lbe-stage canvas { max-width: 100%; max-height: 100%; background: #111; cursor: crosshair; }
.lbe-crop { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); pointer-events: none; }
.lbe-btn {
  border: 0; background: transparent; color: #fff;
  padding: 8px 12px; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer;
}
.lbe-btn:hover { background: rgba(255,255,255,.1); }
.lbe-btn.accent { background: #2ea043; color: #fff; }
.lbe-btn.accent:hover { background: #3fb950; }
.lbe-tools { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; flex: 1; }
.lbe-tool {
  width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: transparent; color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.lbe-tool svg { width: 22px; height: 22px; }
.lbe-tool.on, .lbe-tool:hover { background: rgba(255,255,255,.12); }
.lbe-tool.on { outline: 2px solid #2ea043; }
.lbe-colors { display: flex; gap: 6px; padding: 0 8px; }
.lbe-col {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0;
}
.lbe-col.on { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.lbe-size { width: 90px; }

.media-album {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  width: min(360px, 78vw);
  margin: 6px 8px;
  border-radius: 14px;
  overflow: hidden;
}
.media-album.me { margin-left: auto; }
.media-album.them { margin-right: auto; }
.msg.them.grp .media-album.them { margin-left: 0; }
.media-album .msg { margin: 0 !important; max-width: none; width: auto; }
.media-album .av, .media-album .g-sender { display: none; }
.media-album .bubble { width: 100%; max-width: none !important; padding: 0 !important; border-radius: 0 !important; background: #111; }
.media-album img.photo {
  width: 100% !important; height: 148px !important;
  max-width: none !important; max-height: none !important;
  object-fit: cover; border-radius: 0 !important;
}
.media-album.n-2 img.photo { height: 180px !important; }
.media-album.n-3 .msg.al-0 { grid-column: 1 / -1; }
.media-album.n-3 .msg.al-0 img.photo { height: 210px !important; }
.media-album.n-5 .msg.al-0 { grid-column: 1 / -1; }
.media-album.n-5 .msg.al-0 img.photo { height: 200px !important; }
.media-album.n-6, .media-album.n-7, .media-album.n-8, .media-album.n-9,
.media-album.n-more { grid-template-columns: 1fr 1fr 1fr; }
.media-album.n-6 img.photo, .media-album.n-7 img.photo, .media-album.n-8 img.photo,
.media-album.n-9 img.photo, .media-album.n-more img.photo { height: 110px !important; }
.media-album .msg:not(.al-last) .foot { display: none; }
.media-album .caption { padding: 6px 8px 8px; font-size: 13.5px; }
.media-album .msg:not(.al-last) .caption { display: none; }

.vid-wrap {
  position: relative;
  display: block;
  max-width: min(300px, 70vw);
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  margin-bottom: 6px;
}
.vid-wrap .file-video {
  display: block;
  max-width: 100%;
  max-height: 320px;
  width: 100%;
  background: #000;
}
.vid-open {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border: 0; background: rgba(0,0,0,.18);
  cursor: pointer; padding: 0;
}
.vid-play {
  width: 54px; height: 54px; border-radius: 50%;
  background: rgba(0,0,0,.45);
  box-shadow: 0 0 0 2px rgba(255,255,255,.55);
  position: relative;
}
.vid-play::after {
  content: "";
  position: absolute; left: 21px; top: 16px;
  border-style: solid;
  border-width: 11px 0 11px 18px;
  border-color: transparent transparent transparent #fff;
}
.vid-wrap:hover .vid-open { background: rgba(0,0,0,.28); }

.attach-preview {
  display: flex; flex-direction: column; gap: 8px;
  margin: 0 8px 8px; padding: 10px;
  background: var(--panel, #151c19);
  border: 1px solid var(--line, rgba(255,255,255,.08));
  border-radius: 14px;
}
.attach-preview[hidden] { display: none !important; }
.ap-thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.ap-item {
  position: relative; flex: none;
  width: 72px; height: 72px; border-radius: 10px; overflow: hidden;
  background: #111;
}
.ap-item img, .ap-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ap-item .ap-x {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: 13px; line-height: 20px; padding: 0;
}
.ap-file { display: grid; place-items: center; font-size: 11px; padding: 6px; text-align: center; color: #fff; }
.ap-bar { display: flex; align-items: center; gap: 8px; }
.ap-bar input {
  flex: 1; min-width: 0; border-radius: 10px;
  border: 1px solid var(--line, rgba(255,255,255,.1));
  background: var(--input, rgba(255,255,255,.06));
  color: inherit; font: inherit; padding: 8px 10px;
}
.ap-send, .ap-cancel {
  border: 0; border-radius: 10px; font: inherit; font-weight: 650;
  padding: 8px 12px; cursor: pointer;
}
.ap-cancel { background: transparent; color: inherit; }
.ap-cancel:hover { background: var(--hover, rgba(255,255,255,.06)); }
.ap-send { background: var(--accent, #22c55e); color: var(--on-accent, #052e16); }
.ap-send:hover { filter: brightness(1.08); }

@media (max-width: 720px) {
  .lb-nav { width: 36px; height: 52px; background: rgba(0,0,0,.25); }
  .lb-name { font-size: 14.5px; }
  .vid-wrap, .vid-wrap .file-video { max-width: min(300px, 72vw); }
  .media-album { width: min(300px, 78vw); }
}
/* MULTIPHOTO 26.11.2026: панель выбранных фото — над формой ввода, на всю ширину; кнопки всегда в пределах экрана */
.dock > .attach-preview { margin: 8px 10px 6px; min-width: 0; max-width: calc(100% - 20px); box-sizing: border-box; }
.ap-thumbs { min-width: 0; scrollbar-width: thin; }
.ap-bar { min-width: 0; }
.ap-bar .ap-send, .ap-bar .ap-cancel { flex: none; white-space: nowrap; }
@media (pointer: coarse) {
  .ap-send, .ap-cancel { min-height: 44px; padding: 0 14px; }
  .ap-bar input { min-height: 44px; }
  .ap-item .ap-x { width: 26px; height: 26px; line-height: 26px; font-size: 16px; }
}
/* подпись к нескольким фото (у первого в альбоме) больше не прячется */
.media-album .msg:not(.al-last) .caption { display: block; }
.media-album .msg:not(.al-last) .caption:empty { display: none; }
