/* Regular media follows the current accent/surface tokens. Viewer is always contain. */
.tgios-profile-media-item.is-loading::before{content:'';position:absolute;left:calc(50% - 10px);top:calc(50% - 10px);width:20px;height:20px;border:2px solid #ffffff44;border-top-color:var(--accent,#168dec);border-radius:50%;animation:video-buffer-spin 1s linear infinite}.tgios-profile-media-item.thumbnail-unavailable::before{content:'↻';color:var(--label-secondary,#8e8e93);font-size:26px}
.video-card{position:relative;display:block;width:var(--video-width,360px);max-width:min(360px,72vw,100%);aspect-ratio:var(--video-ratio,16/9);overflow:hidden;border-radius:14px;background:#090c12;isolation:isolate;cursor:pointer}
.video-card>img{width:100%;height:100%;object-fit:contain;display:block}
/* An explicit card width lets the bubble shrink-wrap without percentage cycles.
   Outgoing covers also stay right-aligned when a caption widens the bubble. */
#msgs .mrow.own .msg-content>.video-card{margin-left:auto;margin-right:0}
#msgs .msg-kind-video:has(>.msg-content>.video-card.video-portrait){width:min(var(--portrait-video-width,180px),72vw)}
.video-download-progress{position:absolute;left:8px;top:8px;z-index:4;width:40px;height:40px;border-radius:50%;display:grid;place-items:center;color:#fff;font-size:10px;font-weight:600;font-variant-numeric:tabular-nums;background:conic-gradient(var(--accent,#568af7) var(--download-progress,0%),#ffffff55 0);pointer-events:none;isolation:isolate}
.video-download-progress[hidden]{display:none}
.video-download-progress:before{content:'';position:absolute;inset:3px;border-radius:50%;background:#111d;z-index:-1}

.video-card .video-duration,.video-selection-cell .video-duration{position:absolute;left:9px;top:9px;color:#fff;background:#0009;border-radius:6px;padding:3px 6px;font-size:12px;font-variant-numeric:tabular-nums;pointer-events:none}
.video-play{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:grid;place-items:center;width:54px;height:54px;border-radius:50%;background:#111a;border:1px solid #ffffff45;color:#fff;cursor:pointer;backdrop-filter:blur(6px)}
.video-play svg{width:28px;height:28px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.video-progress{background:conic-gradient(var(--accent,#568af7) var(--upload-progress,0%),#ffffff45 0);border:0;box-shadow:inset 0 0 0 4px #1119}
.video-progress:before{content:'';position:absolute;inset:4px;background:#151c27;border-radius:50%;z-index:-1}
.video-percent{position:absolute;top:calc(100% + 8px);font-size:12px;color:#fff;background:#000a;padding:3px 6px;border-radius:6px}
.video-error{position:absolute;bottom:26px;left:8px;right:8px;text-align:center;color:#fff;background:#000b;padding:6px;border-radius:6px;font-size:12px}
.video-preview-sheet{width:min(720px,94vw);max-height:92dvh;overflow:auto;display:flex;flex-direction:column;background:var(--surface,var(--bg,#fff));border-radius:22px;padding:14px;gap:12px}
.video-preview-stage{position:relative;min-height:160px;height:clamp(180px,46dvh,460px);background:#090c12;overflow:hidden;border-radius:14px;flex-shrink:0}
.video-preview-stage video,.regular-video-surface>video{width:100%;height:100%;object-fit:contain;object-position:center;transform:none}
.video-preview-stage video{height:calc(100% - 52px)}
.video-controls{display:flex;align-items:center;gap:8px;background:#111e;color:#fff;padding:9px 12px;min-height:52px;box-sizing:border-box;font-size:12px;font-variant-numeric:tabular-nums}
.video-controls button,.video-viewer-top button{display:grid;place-items:center;min-width:32px;height:32px;background:transparent;color:#fff;border:0;cursor:pointer;border-radius:8px}
.video-controls svg,.video-viewer-top svg,.video-preview-sheet [data-send] svg{width:24px;height:24px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.video-controls .video-seek{flex:1;min-width:35px;width:100%;accent-color:var(--accent,#568af7);touch-action:pan-x}
.video-controls .video-volume{width:65px;accent-color:var(--accent,#568af7)}
.video-controls select{background:#252a32;color:#fff;border:0;border-radius:6px;padding:5px;max-width:65px}
.video-selection-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(82px,1fr));gap:6px;max-height:190px;overflow:auto}
.video-selection-cell{position:relative;aspect-ratio:1;min-width:0;border-radius:9px;overflow:hidden}
.video-selection-thumb{width:100%;height:100%;padding:0;border:0;cursor:pointer;background:#111}
.video-selection-thumb img{width:100%;height:100%;object-fit:cover;display:block}
.video-select-number{position:absolute;bottom:6px;right:6px;width:26px;height:26px;border:2px solid #fff;border-radius:50%;color:#fff;background:#0007;font-weight:600;cursor:pointer}
.video-select-number[aria-pressed=true]{background:var(--accent,#568af7)}
.regular-video-viewer{background:#05070aee!important;position:fixed!important;inset:0!important;z-index:250;display:grid;place-items:center;padding:0!important}
.regular-video-surface{position:relative;background:#05070a;color:#fff;width:100%;height:100dvh;max-height:100dvh;display:grid;grid-template-rows:minmax(0,1fr);overflow:hidden}
.regular-video-surface>video{position:absolute;inset:0;display:block;width:100%;height:100%}
.video-viewer-top{position:absolute;top:0;left:0;right:0;display:flex;align-items:center;gap:12px;padding:calc(env(safe-area-inset-top,0px) + 12px) max(16px,env(safe-area-inset-right,0px)) 12px max(16px,env(safe-area-inset-left,0px));background:linear-gradient(#000b,transparent);z-index:2}
.video-viewer-top>[data-name]{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.video-viewer-top details{position:relative}.video-viewer-top summary{cursor:pointer;list-style:none;padding:8px}.video-viewer-top details button{background:#252a32;position:absolute;right:0;white-space:nowrap;min-width:110px}
.regular-video-surface>.video-controls{position:absolute;bottom:0;left:0;right:0;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 12px);padding-left:max(12px,env(safe-area-inset-left,0px));padding-right:max(12px,env(safe-area-inset-right,0px));background:linear-gradient(transparent,#000e);z-index:2}
.video-viewer-caption{position:absolute;bottom:calc(env(safe-area-inset-bottom,0px) + 65px);left:16px;right:16px;text-align:center;pointer-events:none;white-space:pre-wrap;text-shadow:0 1px 6px #000;margin:0;font-size:14px;max-height:15dvh;overflow:auto}
.video-viewer-error{position:absolute;left:10%;right:10%;top:46%;color:#fff;text-align:center;background:#111c;border-radius:12px;padding:12px;pointer-events:none}
.video-prev,.video-next{position:absolute;top:45%;border:0;border-radius:50%;width:42px;height:42px;background:#1119;color:#fff;font-size:32px;cursor:pointer}.video-prev{left:12px}.video-next{right:12px}
.video-viewer-top,.regular-video-surface>.video-controls,.video-viewer-caption,.video-prev,.video-next{transition:opacity .18s}
.controls-hidden .video-viewer-top,.controls-hidden .video-controls,.controls-hidden .video-viewer-caption,.controls-hidden .video-prev,.controls-hidden .video-next{opacity:0;pointer-events:none}
.video-album{flex:none;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:3px;width:min(500px,75vw);border-radius:14px;overflow:hidden;margin:4px 0}.video-album.own{align-self:flex-end;margin-left:auto}.video-album.their{margin-right:auto}
.video-album .mrow{margin:0!important;min-width:0;display:block}.video-album .bwrap,.video-album .msg-node{width:100%;max-width:100%;margin:0!important;border-radius:0!important}.video-album .video-card{width:100%;max-width:100%;border-radius:0;aspect-ratio:var(--video-ratio)}
.video-album .msg-content{padding:0}.video-album .msg-caption{padding:8px}.video-album .msg-media-photo{border-radius:0}.video-album .msg-media-photo img{width:100%;height:100%;object-fit:contain}
.video-drop-zone{position:absolute;inset:12px;display:grid;place-items:center;border:2px dashed var(--accent,#568af7);border-radius:22px;background:var(--surface,#fff);opacity:.94;z-index:60;pointer-events:none;font-size:18px}
.video-preview-sheet .attachment-caption textarea{width:100%;box-sizing:border-box;background:var(--surface,var(--bg,#fff));color:var(--text,#172033)}
.tgios-profile-media-item{position:relative}.video-preview-sheet .attachment-mode-seg button{flex:1}
@media(max-width:899px){.video-preview-overlay{align-items:end!important;padding:0!important}.video-preview-sheet{width:100%;max-height:96dvh;border-radius:22px 22px 0 0;padding:14px 14px calc(env(safe-area-inset-bottom,0px) + 14px);box-sizing:border-box;animation:video-sheet-in .18s ease-out}.video-volume{display:none}.video-controls{gap:5px;padding-inline:8px}.video-card{max-width:min(72vw,100%)}.video-album{width:min(500px,79vw)}.video-preview-stage{height:43dvh}.video-controls select{max-width:58px}}
@media(max-height:500px){.video-preview-sheet{display:grid;grid-template-columns:minmax(0,1fr) minmax(180px,.7fr);gap:7px}.video-preview-sheet>.attachment-preview-head{grid-column:1/-1}.video-preview-stage{height:65dvh;grid-row:2/6}.video-selection-grid{max-height:80px}.video-viewer-caption{display:none}}
@keyframes video-sheet-in{from{transform:translateY(30px);opacity:.5}to{transform:none;opacity:1}}
@media(prefers-reduced-motion:reduce){.video-preview-sheet,.video-viewer-top,.video-controls{animation:none!important;transition:none!important}}
[hidden]{display:none!important}
.video-preview-image{width:100%;height:100%;object-fit:contain;display:block}
.video-reply-thumb{width:36px;height:36px;object-fit:contain;border-radius:5px;background:#090c12;margin-right:6px}
.video-failed-cancel{position:absolute;right:6px;top:6px;color:#fff;background:#000a;border:0;border-radius:50%;width:30px;height:30px;display:grid;place-items:center;cursor:pointer}.video-failed-cancel svg{width:20px;height:20px;stroke:currentColor;stroke-width:1.8;fill:none}
.video-viewer-image{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;background:#05070a}
/* Absolute media children must not collapse the overlay's grid track. */
#regularVideoViewer.regular-video-viewer{display:block!important}
#regularVideoViewer>.regular-video-surface{position:absolute;inset:0;width:100%!important;max-width:none!important;height:100%;max-height:none}
#regularVideoViewer[hidden]{display:none!important}
#msgs .video-album .mrow{padding:0!important}
#msgs .video-album .bwrap{max-width:100%!important}
#msgs .video-album .msg-node{padding:0!important;border-radius:0!important}
#msgs .video-album .video-card,#msgs .video-album .msg-media-photo{width:100%;aspect-ratio:1;border-radius:0;max-width:100%}
#msgs .video-album .msg-media-photo img{width:100%;height:100%;min-width:0;object-fit:contain}
.video-album-caption{grid-column:1/-1;background:var(--msg-in,var(--surface,#fff));color:var(--msg-text,var(--text));padding:2px 0 10px}
.video-album.own .video-album-caption{background:var(--msg-out,var(--accent))}

.video-buffering{left:calc(50% - 27px);right:auto;top:calc(50% - 27px);width:54px;height:54px;padding:0;border-radius:50%;font-size:0;background:#111b;border:3px solid #ffffff45;border-top-color:var(--accent,#568af7);animation:video-buffer-spin .8s linear infinite}
@keyframes video-buffer-spin{to{transform:rotate(360deg)}}
.video-file-state .msg-file-card{width:100%;text-align:left;color:inherit}
.video-file-action{display:flex;align-items:center;gap:8px;color:inherit;background:transparent;border:0;padding:8px;cursor:pointer}
.video-viewer-menu{position:absolute;right:0;top:100%;display:flex;flex-direction:column;padding:4px;background:#252a32;border-radius:10px}.video-viewer-top details .video-viewer-menu button{position:static;width:100%;min-width:150px;justify-content:start;white-space:nowrap}
.video-viewer-start{position:absolute;left:calc(50% - 32px);top:calc(50% - 32px);width:64px;height:64px;display:grid;place-items:center;z-index:3;border:1px solid #ffffff66;border-radius:50%;background:#111b;color:#fff;cursor:pointer}.video-viewer-start svg{width:30px;height:30px;fill:currentColor}.video-viewer-retry{position:absolute;top:60%;left:50%;transform:translateX(-50%);z-index:3;padding:12px 20px;border:0;border-radius:12px;background:var(--accent,#568af7);color:#fff;cursor:pointer}.video-viewer-error:not(.video-buffering){top:34%;z-index:2}.video-viewer-top .video-native-player{position:static;white-space:nowrap;background:#252a32;margin-top:4px;min-width:150px}
.video-file-action .video-percent{position:static;background:transparent;color:inherit;padding:0}
.video-file-action svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.8}

#replyBar>.video-reply-thumb{flex:none;margin:0 8px;width:36px;height:36px}

.video-download-link{position:fixed;left:50%;bottom:calc(env(safe-area-inset-bottom,0px) + 80px);transform:translateX(-50%);z-index:300;max-width:85vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-radius:12px;padding:12px 16px;background:var(--surface,#252a32);color:var(--accent,#568af7);box-shadow:0 4px 20px #0005;text-decoration:none}

#msgs .video-album .video-album-wide{grid-column:1/-1}
#msgs .video-album .video-album-wide .video-card,#msgs .video-album .video-album-wide .msg-media-photo{aspect-ratio:2}

/* Accessible targets and one scrolling sheet across keyboard/orientation changes. */
.video-play{padding:0!important;border-radius:50%!important}
#msgs .msg-kind-video{width:fit-content;max-width:100%}
.msg-reply:has(>.video-reply-thumb){grid-template-columns:36px 3px minmax(0,1fr);gap:7px}
.msg-reply>.video-reply-thumb{margin:0}
.video-preview-sheet{box-sizing:border-box;overscroll-behavior:contain;scrollbar-gutter:stable;background:var(--sheet,var(--panel,var(--bg,#fff)))}
.video-preview-overlay>.video-preview-sheet{width:min(720px,94vw)!important;max-width:720px!important;background:var(--surface-primary,var(--panel,var(--bg)))!important}
.video-preview-stage{height:clamp(160px,38dvh,420px)}
.video-selection-grid{flex:none;min-height:82px}
.video-preview-sheet>.attachment-preview-head{flex:none;min-height:44px}
.video-preview-sheet .attachment-preview-head button,.video-preview-sheet .attachment-mode-seg button{min-height:44px}
.video-controls button,.video-viewer-top button{min-width:44px;height:44px;padding:8px}
.video-controls{min-height:64px}
.video-preview-stage video{height:calc(100% - 64px)}
.video-controls select{min-height:44px;cursor:pointer}
.video-controls input[type=range]{height:28px}
.video-controls button:focus-visible,.video-selection-cell button:focus-visible,.video-viewer-top summary:focus-visible{outline:2px solid var(--accent,#568af7);outline-offset:-2px}
.video-select-number{width:44px;height:44px;bottom:0;right:0;border-width:0;background:transparent!important;isolation:isolate}
.video-select-number:before{content:'';position:absolute;inset:7px;z-index:-1;background:#0009;border:2px solid #fff;border-radius:50%}
.video-select-number[aria-pressed=true]:before{background:var(--accent,#568af7)}
.video-failed-cancel,.video-prev,.video-next{width:44px;height:44px}
.video-viewer-top summary{box-sizing:border-box;min-width:44px;min-height:44px;display:grid;place-items:center}
.video-viewer-top details button{height:auto;min-height:44px;padding:10px 14px;box-shadow:0 6px 24px #0006}
.video-preview-sheet textarea{box-sizing:border-box;width:100%;resize:none;max-height:120px}
@media(max-width:600px){
  .video-preview-overlay>.video-preview-sheet{width:100%!important;max-width:100%!important;border-radius:22px 22px 0 0!important}
  .video-controls{display:grid;grid-template-columns:44px minmax(30px,1fr) minmax(30px,1fr) 44px 58px 44px;gap:2px;min-height:96px;padding:4px 8px}
  .video-controls .video-seek{grid-column:1/-1;grid-row:1;height:28px;margin:0}
  .video-controls [data-duration]{text-align:right}
  .video-controls [data-speed]{width:58px;max-width:58px}
  .video-preview-stage video{height:calc(100% - 96px)}
  .video-viewer-caption{bottom:calc(env(safe-area-inset-bottom,0px) + 110px)}
}
@media(max-height:500px){
  .video-preview-sheet{max-height:96dvh;grid-template-rows:auto minmax(0,1fr) auto auto auto;padding-top:max(8px,env(safe-area-inset-top,0px));padding-bottom:max(8px,env(safe-area-inset-bottom,0px))}
  .video-preview-stage{height:100%;min-height:140px;grid-row:2/6}
  .video-selection-grid{max-height:70px}
  .video-selection-grid{min-height:60px}
  .video-preview-sheet textarea{max-height:60px;min-height:44px}
  .video-preview-sheet .attachment-preview-actions{margin:0}
}
@media(prefers-reduced-motion:reduce){.video-buffering{animation-duration:2s}}
:root[data-power-transitions='0'] .video-preview-sheet,:root[data-power-transitions='0'] .video-viewer-top,:root[data-power-transitions='0'] .video-controls{animation:none!important;transition:none!important}

.video-quality{display:grid;gap:4px;flex-shrink:0;padding:4px 2px}.video-quality label{display:grid;grid-template-columns:1fr auto;align-items:center;gap:8px;font-size:14px}.video-quality output{font-weight:600;color:var(--accent,#168dec)}.video-quality input{grid-column:1/-1;width:100%;min-height:32px;margin:0;accent-color:var(--accent,#168dec);touch-action:pan-y}.video-quality-ticks{display:flex;justify-content:space-between;gap:4px;font-size:11px;color:var(--muted,#748294)}.video-quality small{font-size:11px;color:var(--muted,#748294)}.video-quality.is-disabled{opacity:.55}

.video-quality-processing{position:fixed;right:12px;bottom:calc(env(safe-area-inset-bottom,0px) + 84px);z-index:2000;width:180px;height:134px;padding:8px;border:1px solid var(--border,#d6dce5);border-radius:12px;background:var(--surface-primary,var(--bg,#fff));color:var(--text,#172033);box-shadow:0 4px 20px #0002;pointer-events:none;font:11px system-ui}.video-quality-processing output{float:right}.video-quality-processing video,.video-quality-processing canvas{position:absolute;top:34px;left:8px;width:180px;height:102px;object-fit:contain;border-radius:6px;background:#090c12}

/* Video presentation v1. Keep all existing controls, handlers and hidden states.
   Selection thumbnails show selected files, not fabricated timeline frames. */
:root{
  --video-bg:#000;
  --video-surface:#1c1c1e;
  --video-dialog-bg:#242424;
  --video-popup:rgba(41,49,59,.95);
  --video-text:#fff;
  --video-secondary:#aeb5bd;
  --video-tertiary:#858c96;
  --video-overlay:rgba(0,0,0,.45);
  --video-divider:rgba(255,255,255,.12);
  --video-track:rgba(255,255,255,.35);
  --video-popup-radius:12px;
  --video-target:44px;
  --video-send-size:46px;
  --video-play-size:52px;
  --video-gap:8px;
  --video-pad:16px;
  --video-pad-desktop:24px;
  --video-font-title:18px;
  --video-font-label:14px;
  --video-font-detail:12px;
  --video-motion-press:120ms;
  --video-motion-menu:180ms;
  --video-motion-panel:220ms;
}
/* Preview has no sound or controls; the existing card button opens the viewer. */
.video-card>.video-chat-preview{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;background:#000;pointer-events:none;opacity:0;z-index:1}
.video-card.video-preview-playing>.video-chat-preview{opacity:1}
.video-card>.video-play,.video-card>.video-duration{z-index:2}
html[data-theme='light']{--video-dialog-bg:#fff}
.video-preview-overlay{
  background:rgba(0,0,0,.55)!important;
  padding:var(--video-pad-desktop)!important;
  color-scheme:dark;
}
.video-preview-overlay>.video-preview-sheet{
  --video-ink:var(--label-primary,#fff);
  --video-muted:var(--label-secondary,#aeb5bd);
  --video-line:var(--separator,#ffffff1f);
  width:min(560px,calc(100vw - 32px))!important;
  max-width:560px!important;
  max-height:calc(100dvh - 48px)!important;
  display:grid;
  grid-template-columns:minmax(0,1fr) var(--video-send-size);
  grid-template-areas:'head head' 'stage stage' 'notice notice' 'selection selection' 'mode mode' 'quality quality' 'caption send';
  gap:12px;
  padding:var(--video-pad-desktop)!important;
  border:0;
  border-radius:14px!important;
  background:var(--video-dialog-bg)!important;
  color:var(--video-ink);
  box-shadow:0 16px 48px rgba(0,0,0,.35);
  scrollbar-width:thin;
  scrollbar-gutter:auto;
  font-family:inherit;
}
.video-preview-sheet::before{display:none!important}
.video-preview-sheet>.attachment-preview-head{
  grid-area:head;
  grid-template-columns:44px minmax(0,1fr) 44px;
  min-height:44px;
  gap:8px;
  margin:0;
}
.video-preview-sheet .attachment-preview-head strong{font-size:var(--video-font-title);font-weight:600;letter-spacing:-.2px;color:var(--video-ink)!important}
.video-preview-sheet .attachment-preview-head [data-close]{
  display:grid;place-items:center;width:44px;height:44px;padding:0;
  color:var(--video-ink);font-size:0;border-radius:50%!important;
}
.video-preview-sheet .attachment-preview-head [data-close]::before{
  content:'';width:14px;height:14px;border-left:1.8px solid currentColor;
  border-bottom:1.8px solid currentColor;transform:rotate(45deg);margin-left:5px;
}
.video-preview-sheet [data-count]{
  justify-self:end;display:grid;place-items:center;width:28px;height:28px;
  border-radius:50%;background:var(--accent,#168dec);color:#fff;
  font-size:14px;font-weight:600;font-variant-numeric:tabular-nums;
}
.video-preview-sheet>.video-preview-stage{
  grid-area:stage;height:clamp(200px,36dvh,440px);min-height:150px;
  border-radius:8px;background:#000;flex-shrink:1;
}
.video-preview-sheet .video-preview-stage>video{height:calc(100% - 80px);background:var(--video-bg)}
.video-preview-sheet .video-preview-image{object-fit:contain;background:#000}
.video-preview-sheet>.video-preview-notice{
  grid-area:notice;margin:0;padding:0;font-size:12px;line-height:1.45;color:var(--video-muted);
}
.video-preview-sheet>.video-selection-grid{
  grid-area:selection;display:flex;gap:4px;min-height:44px;max-height:44px;
  overflow-x:auto;overflow-y:hidden;scrollbar-width:none;padding:0;
}
.video-preview-sheet .video-selection-cell{flex:0 0 56px;height:44px;aspect-ratio:auto;border-radius:6px;background:var(--video-bg)}
.video-preview-sheet .video-selection-thumb img{object-fit:contain}
.video-preview-sheet .video-select-number{width:44px;height:44px;bottom:0;right:0;font-size:12px}
.video-preview-sheet .video-select-number::before{inset:11px;border-width:1.5px}
.video-preview-sheet .video-selection-cell .video-duration{top:4px;left:4px;padding:2px 4px;font-size:10px;border-radius:4px}
.video-preview-sheet>.attachment-mode-seg{
  grid-area:mode;display:flex;gap:4px;padding:0;background:var(--video-line);border-radius:8px;
}
.video-preview-sheet .attachment-mode-seg button{
  min-height:44px;padding:8px 12px;font-size:13px;font-weight:500;
  border-radius:6px;color:var(--video-muted);background:transparent;box-shadow:none;
}
.video-preview-sheet .attachment-mode-seg button.on{background:var(--video-dialog-bg);color:var(--video-ink);box-shadow:none}
.video-preview-sheet>.video-quality{grid-area:quality;padding:12px 0 8px;gap:4px;color:var(--video-ink)}
.video-preview-sheet .video-quality label{gap:12px;font-size:var(--video-font-label);font-weight:400}
.video-preview-sheet .video-quality output{font-size:13px;font-weight:500;color:var(--video-ink)}
.video-preview-sheet .video-quality input{
  position:relative;z-index:1;width:calc(100% - 22px);height:36px;min-height:36px;
  margin:0 11px;background:transparent;appearance:none;-webkit-appearance:none;
}
.video-preview-sheet .video-quality-ticks{
  display:flex;justify-content:space-between;padding:0 19px;
  height:18px;gap:0;font-size:11px;line-height:18px;color:var(--video-muted);
}
.video-preview-sheet .video-quality-ticks>span{
  position:relative;display:flex;justify-content:center;flex:0 0 0;width:0;white-space:nowrap;
}
.video-preview-sheet .video-quality-ticks>span::before{
  content:'';position:absolute;top:-25.5px;left:-3.5px;width:7px;height:7px;
  background:#727272;border-radius:50%;pointer-events:none;
}
.video-preview-sheet .video-quality small{color:var(--video-muted);font-size:var(--video-font-detail);line-height:1.35;margin-top:4px}
.video-preview-sheet>.attachment-caption{grid-area:caption;min-width:0;align-self:end;margin:0}
.video-preview-sheet .attachment-caption textarea{
  display:block;
  min-height:48px;height:68px;max-height:120px;padding:12px;
  font:inherit;font-size:16px;line-height:22px;border:0;border-radius:10px;
  background:var(--surface-secondary,#303030);color:var(--video-ink);caret-color:var(--accent,#168dec);
}
.video-preview-sheet .attachment-caption textarea::placeholder{color:var(--video-muted);opacity:1}
@supports(field-sizing:content){
  .video-preview-sheet .attachment-caption textarea{field-sizing:content;height:auto}
}
.video-preview-sheet>.attachment-preview-actions{grid-area:send;align-self:end;margin:0;height:var(--video-send-size)}
.video-preview-sheet .attachment-preview-actions [data-send]{
  width:var(--video-send-size)!important;min-width:var(--video-send-size)!important;height:var(--video-send-size)!important;
  padding:12px!important;border:0!important;border-radius:50%!important;
  background:var(--accent,#168dec)!important;color:#fff!important;box-shadow:none!important;
}
.video-preview-sheet [data-send] svg{width:23px;height:23px;stroke-width:1.7}

/* Thin native ranges keep keyboard, touch, value and event behavior intact. */
.video-controls input[type=range]{
  appearance:none;-webkit-appearance:none;box-sizing:border-box;height:28px;
  padding:0;margin:0;background:transparent;cursor:pointer;
}
.video-controls input[type=range]::-webkit-slider-runnable-track{height:3px;border-radius:2px;background:var(--video-track)}
.video-preview-sheet .video-quality input::-webkit-slider-runnable-track{height:2px;border-radius:2px;background:var(--video-muted)}
.video-controls input[type=range]::-webkit-slider-thumb,
.video-preview-sheet .video-quality input::-webkit-slider-thumb{
  appearance:none;-webkit-appearance:none;width:12px;height:12px;
  margin-top:-5px;border:0;border-radius:50%;background:#fff;box-shadow:0 1px 3px #0005;
}
.video-preview-sheet .video-quality input::-webkit-slider-thumb{width:16px;height:16px;margin-top:-7px;background:var(--video-ink)}
.video-controls input[type=range]::-moz-range-track{height:3px;border:0;border-radius:2px;background:var(--video-track)}
.video-preview-sheet .video-quality input::-moz-range-track{height:2px;border:0;border-radius:2px;background:var(--video-muted)}
.video-controls input[type=range]::-moz-range-thumb,
.video-preview-sheet .video-quality input::-moz-range-thumb{width:12px;height:12px;border:0;border-radius:50%;background:#fff}
.video-preview-sheet .video-quality input::-moz-range-thumb{width:16px;height:16px;background:var(--video-ink)}
.video-controls input[type=range]::-moz-range-progress{height:2px;background:#eee}
.video-controls input[type=range]:focus-visible,.video-quality input:focus-visible{outline:2px solid var(--accent,#168dec);outline-offset:2px;border-radius:6px}
.video-preview-sheet input:disabled{cursor:default}
.video-preview-sheet .video-quality.is-disabled{opacity:.5}
.video-preview-sheet .video-controls{
  position:static;display:grid;height:80px;min-height:80px;padding:0 12px 8px;
  grid-template-columns:44px 48px minmax(24px,1fr) 48px 44px 60px 58px;
  grid-template-rows:28px 44px;gap:0 4px;background:var(--video-bg);color:#eee;
}
.video-preview-sheet .video-controls .video-seek{grid-column:1/-1;grid-row:1;width:100%}
.video-preview-sheet .video-controls [data-play]{grid-column:1;grid-row:2}
.video-preview-sheet .video-controls [data-time]{grid-column:2;grid-row:2}
.video-preview-sheet .video-controls [data-duration]{grid-column:4;grid-row:2;text-align:right}
.video-preview-sheet .video-controls [data-mute]{grid-column:5;grid-row:2}
.video-preview-sheet .video-controls [data-volume]{grid-column:6;grid-row:2;width:60px}
.video-preview-sheet .video-controls [data-speed]{grid-column:7;grid-row:2}
.video-preview-sheet .video-controls [data-play]:has(path[fill='currentColor']){
  position:absolute;left:50%;top:calc((100% - 80px)/2);transform:translate(-50%,-50%);
  width:var(--video-play-size);height:var(--video-play-size);border-radius:50%;background:var(--video-overlay);backdrop-filter:blur(5px);
}
.video-controls button,.video-viewer-top button{border-radius:50%;transition:background-color var(--video-motion-press),opacity var(--video-motion-press)}
.video-controls button{border-radius:50%!important}
.video-controls select{
  appearance:none;-webkit-appearance:none;min-height:40px;padding:6px 2px;
  width:58px;max-width:58px;text-align:center;background:transparent;color:#eee;
  font:inherit;font-size:13px;border-radius:8px;
}
.video-controls select option{background:#242426;color:#fff}
.video-controls svg,.video-viewer-top svg{width:22px;height:22px;stroke-width:1.7}

/* Existing playback state owns auto-hide, retries and the system-player fallback. */
.regular-video-viewer{background:#000!important;color-scheme:dark}
.regular-video-surface,.video-viewer-image{background:#000}
.video-viewer-top{
  min-height:52px;box-sizing:border-box;gap:4px;
  padding:calc(env(safe-area-inset-top,0px) + 4px) max(12px,env(safe-area-inset-right,0px)) 4px max(12px,env(safe-area-inset-left,0px));
  background:linear-gradient(rgba(0,0,0,.48),transparent);
}
.video-viewer-top>[data-name]{font-size:14px;font-weight:500;letter-spacing:-.1px}
.video-viewer-top summary{width:44px;height:44px;padding:0;font-size:24px;line-height:1;letter-spacing:1px;border-radius:50%;color:#fff}
.video-viewer-top summary::-webkit-details-marker{display:none}
.video-viewer-top details[open] summary{background:#ffffff16}
.video-viewer-top:has(details[open]){z-index:4}
.video-viewer-menu{
  top:calc(100% + 8px);right:0;width:204px;min-width:0;max-width:calc(100vw - 24px);
  max-height:calc(var(--vvh,100dvh) - 100px);overflow:auto;
  box-sizing:border-box;padding:4px;background:var(--video-popup);border-radius:var(--video-popup-radius);
  box-shadow:0 8px 32px rgba(0,0,0,.35);backdrop-filter:blur(16px);
  transform-origin:top right;animation:video-menu-in var(--video-motion-menu) ease-out;
}
.video-viewer-top details .video-viewer-menu button{
  display:flex;align-items:center;gap:12px;min-height:46px;padding:10px 12px;
  width:100%;border-radius:7px;background:transparent;box-shadow:none;
  color:#f5f5f7;font:inherit;font-size:14px;text-align:left;
}
.video-viewer-top .video-viewer-menu button::before{content:'';flex:none;width:20px;height:20px;background:currentColor}
.video-viewer-menu [data-save]::before{mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12m-4-4 4 4 4-4M5 17v4h14v-4'/%3E%3C/svg%3E") center/contain no-repeat}
.video-viewer-menu .video-native-player::before{clip-path:polygon(20% 10%,88% 50%,20% 90%)}
.video-viewer-top .video-native-player{margin-top:0}
.regular-video-surface>.video-controls{
  min-height:68px;gap:10px;padding-top:18px;
  padding-bottom:calc(env(safe-area-inset-bottom,0px) + 12px);
  padding-left:max(20px,env(safe-area-inset-left,0px));padding-right:max(20px,env(safe-area-inset-right,0px));
  background:linear-gradient(transparent,rgba(0,0,0,.25) 50%,rgba(0,0,0,.7));
}
.video-viewer-caption{bottom:calc(env(safe-area-inset-bottom,0px) + 78px);font-size:14px;line-height:1.45;color:#ededf0}
.video-viewer-start{
  width:56px;height:56px;left:calc(50% - 28px);top:calc(50% - 28px);
  border:0;border-radius:50%!important;background:#0007;backdrop-filter:blur(6px);
}
.video-viewer-start svg{width:26px;height:26px}
.video-viewer-top,.regular-video-surface>.video-controls,.video-viewer-caption,.video-prev,.video-next{transition:opacity var(--video-motion-panel) ease-out}
.video-play{width:50px;height:50px;border:0;background:var(--video-overlay);backdrop-filter:blur(5px)}
.video-play svg{width:22px;height:22px}
.video-card{max-width:min(400px,80vw,100%);border-radius:14px;background:#000}
.video-card .video-duration{top:auto;bottom:8px;left:8px;padding:3px 6px;font-size:11px;border-radius:5px;background:rgba(0,0,0,.6)}
.video-percent{font-variant-numeric:tabular-nums}
.video-progress{width:46px;height:46px;background:conic-gradient(#fff var(--upload-progress,0%),#ffffff45 0);box-shadow:inset 0 0 0 2.5px #1119}
.video-progress::before{inset:2.5px}
.video-progress::before{background:#141416}
.video-buffering{border-width:2px;background:#0007}

@media(hover:hover){
  .video-controls button:hover,.video-viewer-top button:hover,.video-viewer-top summary:hover,
  .video-preview-sheet .attachment-preview-head button:hover{background-color:#ffffff12}
  .video-controls select:hover{background:#ffffff10}
  .video-play:hover{background:#0009}
}
.video-controls button:active,.video-viewer-top button:active,.video-preview-sheet [data-send]:active{opacity:.72}
.video-preview-sheet [data-close]:focus-visible,.video-preview-sheet [data-send]:focus-visible,
.video-viewer-menu button:focus-visible{outline:2px solid var(--accent,#168dec);outline-offset:2px}
@keyframes video-menu-in{from{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}
@media(max-width:899px){
  .video-preview-overlay{
    position:fixed!important;inset:var(--vv-top,0px) 0 auto!important;
    height:var(--vvh,100dvh)!important;padding:0!important;align-items:stretch!important;
    background:var(--video-bg)!important;
  }
  .video-preview-overlay>.video-preview-sheet{
    width:100%!important;max-width:100%!important;height:100%!important;max-height:100%!important;
    --video-ink:var(--video-text);--video-muted:var(--video-secondary);--video-line:var(--video-divider);
    grid-template-rows:52px minmax(100px,1fr) auto 44px 44px auto minmax(48px,auto);
    gap:8px 12px;border-radius:0!important;box-shadow:none;
    padding:env(safe-area-inset-top,0px) max(var(--video-pad),env(safe-area-inset-right,0px)) calc(env(safe-area-inset-bottom,0px) + 12px) max(var(--video-pad),env(safe-area-inset-left,0px))!important;
    background:var(--video-bg)!important;animation:video-sheet-in var(--video-motion-panel) ease-out;
  }
  .video-preview-sheet>.video-preview-stage{height:100%;min-height:100px;border-radius:0}
  .video-preview-overlay>.video-preview-sheet:has(.video-selection-cell:only-child){
    grid-template-columns:56px minmax(0,1fr) var(--video-send-size);
    grid-template-areas:'head head head' 'stage stage stage' 'notice notice notice' 'selection mode mode' 'quality quality quality' 'caption caption send';
    grid-template-rows:52px minmax(100px,1fr) auto 44px auto minmax(48px,auto);
  }
  .video-preview-sheet .video-controls{
    grid-template-columns:44px 42px minmax(8px,1fr) 42px 44px 48px;
    padding-inline:4px;gap:0 2px;
  }
  .video-preview-sheet .video-controls [data-speed]{grid-column:6;width:48px;max-width:48px}
  .video-preview-sheet .video-controls [data-volume]{display:none}
  .video-preview-sheet .attachment-mode-seg button.on{background:var(--video-surface)}
  .video-preview-sheet .attachment-caption textarea{background:var(--video-surface);border-radius:12px}
  .video-preview-sheet .attachment-caption textarea::placeholder{color:#8e8e93}
  .video-preview-sheet>.attachment-caption,.video-preview-sheet>.attachment-preview-actions{position:sticky;bottom:0;z-index:4}
  .video-card{max-width:min(80vw,100%)}
}
@media(max-width:600px){
  .regular-video-surface>.video-controls{
    display:grid;grid-template-columns:44px minmax(0,1fr) 48px minmax(0,1fr) 44px;
    grid-template-rows:28px 18px 48px;gap:0;
    padding:12px max(16px,env(safe-area-inset-right,0px)) calc(env(safe-area-inset-bottom,0px) + 10px) max(16px,env(safe-area-inset-left,0px));
  }
  .regular-video-surface>.video-controls .video-seek{grid-column:1/-1;grid-row:1;width:100%}
  .regular-video-surface>.video-controls [data-time]{grid-column:1/3;grid-row:2;align-self:start}
  .regular-video-surface>.video-controls [data-duration]{grid-column:4/6;grid-row:2;align-self:start;text-align:right}
  .regular-video-surface>.video-controls [data-play]{grid-column:3;grid-row:3;width:48px;height:48px}
  .regular-video-surface>.video-controls [data-play] svg{width:27px;height:27px}
  .regular-video-surface>.video-controls [data-mute]{grid-column:1;grid-row:3}
  .regular-video-surface>.video-controls [data-speed]{grid-column:4;grid-row:3;justify-self:end;width:48px;max-width:48px}
  .regular-video-surface>.video-controls [data-full]{grid-column:5;grid-row:3}
  .video-viewer-caption{bottom:calc(env(safe-area-inset-bottom,0px) + 128px)}
}
@media(min-width:500px) and (max-height:500px) and (orientation:landscape){
  .video-preview-overlay>.video-preview-sheet,
  .video-preview-overlay>.video-preview-sheet:has(.video-selection-cell:only-child){
    grid-template-columns:minmax(0,1fr) minmax(200px,.65fr) 48px;
    grid-template-areas:'head head head' 'stage selection selection' 'stage mode mode' 'stage quality quality' 'stage notice notice' 'stage caption send';
    grid-template-rows:44px 44px 44px auto auto 48px;gap:4px 12px;
    padding-top:max(4px,env(safe-area-inset-top,0px))!important;
    padding-bottom:max(6px,env(safe-area-inset-bottom,0px))!important;
  }
  .video-preview-sheet>.video-preview-stage{height:100%;min-height:100px}
  .video-preview-sheet>.video-quality{padding:0}
  .video-preview-sheet .video-quality small{display:none}
  .video-preview-sheet .attachment-caption textarea{max-height:48px}
  .regular-video-surface>.video-controls{display:flex;min-height:56px;gap:8px;padding-top:12px;padding-bottom:max(6px,env(safe-area-inset-bottom,0px))}
  .regular-video-surface>.video-controls .video-seek{flex:1;width:auto;min-width:40px}
  .video-viewer-top{padding-top:max(4px,env(safe-area-inset-top,0px));min-height:48px}
}
@media(max-width:359px){
  .video-preview-overlay>.video-preview-sheet{padding-inline:max(12px,env(safe-area-inset-left,0px)) max(12px,env(safe-area-inset-right,0px))!important}
}
@media(min-width:900px){
  .video-preview-overlay>.video-preview-sheet{grid-template-columns:minmax(0,1fr) 120px}
  .video-preview-sheet>.attachment-preview-head{grid-template-columns:minmax(0,1fr) 32px 44px;min-height:48px}
  .video-preview-sheet .attachment-preview-head strong{grid-column:1;grid-row:1;text-align:left}
  .video-preview-sheet .attachment-preview-head [data-count]{grid-column:2;grid-row:1}
  .video-preview-sheet .attachment-preview-head [data-close]{grid-column:3;grid-row:1}
  .video-preview-sheet .attachment-preview-head [data-close]::before{
    width:20px;height:20px;margin:0;border:0;transform:none;background:currentColor;
    mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='m6 6 12 12M18 6 6 18'/%3E%3C/svg%3E") center/contain no-repeat;
  }
  .video-preview-sheet .attachment-preview-actions [data-send]{
    display:flex!important;align-items:center;justify-content:center;gap:8px;
    width:120px!important;min-width:120px!important;height:40px!important;
    padding:8px 16px!important;border-radius:9px!important;
  }
  .video-preview-sheet .attachment-preview-actions [data-send]::after{content:attr(aria-label);font:inherit;font-size:14px}
  .video-preview-sheet .attachment-preview-actions [data-send] svg{width:20px;height:20px;flex:none}
}
@media(prefers-reduced-motion:reduce){
  .video-preview-overlay>.video-preview-sheet,.video-viewer-menu{animation:none!important}
  .video-controls button,.video-viewer-top button,.video-viewer-top,.video-viewer-caption{transition:none!important}
}
:root[data-power-transitions='0'] .video-viewer-menu{animation:none!important}

/* Native seek input stays accessible; separate layers expose real buffering. */
.video-seek{position:relative;display:flex;align-items:center;height:28px;min-width:35px}
.video-seek-track{position:absolute;left:6px;right:6px;top:calc(50% - 2px);height:4px;border-radius:3px;background:#ffffff30;overflow:hidden;pointer-events:none}
.video-seek-track [data-buffered]{position:absolute;inset:0}
.video-buffered-range{position:absolute;top:0;height:100%;background:#a8afb9}
.video-seek-track [data-played]{position:absolute;left:0;top:0;height:100%;background:#168dec}
.video-controls .video-seek input[data-seek]{position:relative;z-index:1;width:100%;min-width:0;margin:0}
.video-controls .video-seek input::-webkit-slider-runnable-track{background:transparent;height:4px}
.video-controls .video-seek input::-moz-range-track,.video-controls .video-seek input::-moz-range-progress{background:transparent;height:4px}
.video-controls .video-seek input::-webkit-slider-thumb{background:#168dec;margin-top:-4px}
.video-controls .video-seek input::-moz-range-thumb{background:#168dec}
.regular-video-surface .video-buffering{left:50%;right:auto;top:50%;transform:translate(-50%,-50%);width:max-content;max-width:90%;height:auto;padding:12px 18px;border:0;border-radius:16px;font-size:14px;line-height:1.5;background:#0009;animation:none;text-align:center;pointer-events:none;z-index:3}
.video-buffering::before{content:'';display:block;box-sizing:border-box;width:44px;height:44px;margin:0 auto 9px;border:2px solid #ffffff45;border-top-color:#168dec;border-radius:50%;animation:video-buffer-spin .8s linear infinite}
.video-download-status{position:absolute;bottom:calc(90px + env(safe-area-inset-bottom,0px));right:24px;padding:4px 8px;border-radius:8px;background:#0008;color:#ddd;font-size:12px;pointer-events:none;z-index:2;transition:opacity .18s}
.controls-hidden .video-download-status{opacity:0}
@media(max-width:600px){.video-download-status{bottom:calc(142px + env(safe-area-inset-bottom,0px));right:16px}}
@media(prefers-reduced-motion:reduce){.video-buffering::before{animation-duration:2s}}

/* Photos in mixed albums use the same contained-image zoom as single photos. */
.regular-video-surface.photo-viewer-surface{display:flex;align-items:center;justify-content:center;touch-action:none}
.regular-video-surface.photo-viewer-surface>.video-viewer-image{
  position:relative;inset:auto;width:auto;height:auto;max-width:100%;max-height:100%;
  object-fit:contain;transform-origin:center;touch-action:none;user-select:none;-webkit-user-drag:none;
}
.regular-video-surface.photo-viewer-surface>.photo-zoom-controls{
  top:calc(max(12px,var(--sat,0px)) + 52px);left:50%;transform:translateX(-50%);
}
.regular-video-viewer.controls-hidden .photo-zoom-controls{opacity:0;pointer-events:none}
